# bqhus
[![Maintainability](https://api.codeclimate.com/v1/badges/102f4aceaa6a1c544f52/maintainability)](https://codeclimate.com/github/yokoe/bqhus/maintainability)
BigQuery helper utils for Python
## How to use
### Select from table
```
import bqhus
bqhus.select("SELECT * FROM `foo.bar.purchases` LIMIT 20").as_dicts()
bqhus.select("SELECT * FROM `foo.bar.purchases` ORDER BY created_at LIMIT 1", client=bigquery.Client(project="foobar")).first_as_dict()
bqhus.select("SELECT * FROM `foo.bar.purchases` LIMIT 20").to_dataframe()
```
### Create table from query
```
bqhus.select("SELECT * FROM `some.source.table`").to_table("foo.bar.new_table")
```
### Create temp table from query
```
bqhus.select("SELECT * FROM `some.source.table`").to_table("foo.bar.new_table").expires_in(days=7)
```
### Export table to GCS as csv
```
bqhus.export_table("foo.bar.sample").as_csv(gzip=True).to_gcs("my-bucket", "exported-table.csv.gz")
```
### Generate random table name
```
bqhus.random_table_name("prefix-here")
```
## Development
### Run tests
```
docker compose run bqhus
```
Raw data
{
"_id": null,
"home_page": "https://github.com/yokoe/bqhus",
"name": "bqhus",
"maintainer": "yokoe",
"docs_url": null,
"requires_python": "",
"maintainer_email": "kreuz45@kreuz45.com",
"keywords": "bigquery",
"author": "yokoe",
"author_email": "kreuz45@kreuz45.com",
"download_url": "https://files.pythonhosted.org/packages/53/7f/457b1c0fc74ffdb74d201a2e02d3547ae5cbf82bfed1bc8be6dcc13b62d4/bqhus-0.1.11.tar.gz",
"platform": null,
"description": "# bqhus\n[![Maintainability](https://api.codeclimate.com/v1/badges/102f4aceaa6a1c544f52/maintainability)](https://codeclimate.com/github/yokoe/bqhus/maintainability)\n\nBigQuery helper utils for Python\n\n## How to use\n### Select from table\n```\nimport bqhus\nbqhus.select(\"SELECT * FROM `foo.bar.purchases` LIMIT 20\").as_dicts()\nbqhus.select(\"SELECT * FROM `foo.bar.purchases` ORDER BY created_at LIMIT 1\", client=bigquery.Client(project=\"foobar\")).first_as_dict()\nbqhus.select(\"SELECT * FROM `foo.bar.purchases` LIMIT 20\").to_dataframe()\n```\n\n### Create table from query\n```\nbqhus.select(\"SELECT * FROM `some.source.table`\").to_table(\"foo.bar.new_table\")\n```\n\n### Create temp table from query\n```\nbqhus.select(\"SELECT * FROM `some.source.table`\").to_table(\"foo.bar.new_table\").expires_in(days=7)\n```\n\n### Export table to GCS as csv\n```\nbqhus.export_table(\"foo.bar.sample\").as_csv(gzip=True).to_gcs(\"my-bucket\", \"exported-table.csv.gz\")\n```\n\n\n### Generate random table name\n```\nbqhus.random_table_name(\"prefix-here\")\n```\n\n## Development\n### Run tests\n```\ndocker compose run bqhus\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "bqhus: BigQuery helper utils.",
"version": "0.1.11",
"project_urls": {
"Download": "https://github.com/yokoe/bqhus",
"Homepage": "https://github.com/yokoe/bqhus"
},
"split_keywords": [
"bigquery"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "537f457b1c0fc74ffdb74d201a2e02d3547ae5cbf82bfed1bc8be6dcc13b62d4",
"md5": "94cdbdfa04a4ea113f2840e69d45d4c1",
"sha256": "32d6b3acd201c5f7019fd619fdeba6beb745ab9395aa344011562f73469a8ce7"
},
"downloads": -1,
"filename": "bqhus-0.1.11.tar.gz",
"has_sig": false,
"md5_digest": "94cdbdfa04a4ea113f2840e69d45d4c1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5342,
"upload_time": "2023-05-30T01:26:07",
"upload_time_iso_8601": "2023-05-30T01:26:07.986914Z",
"url": "https://files.pythonhosted.org/packages/53/7f/457b1c0fc74ffdb74d201a2e02d3547ae5cbf82bfed1bc8be6dcc13b62d4/bqhus-0.1.11.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-30 01:26:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yokoe",
"github_project": "bqhus",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "bqhus"
}