Name | shipyard-bigquery JSON |
Version |
0.1.4
JSON |
| download |
home_page | None |
Summary | A local client for connecting to and working with Google BigQuery |
upload_time | 2024-03-21 19:55:15 |
maintainer | None |
docs_url | None |
author | wrp801 |
requires_python | <4.0,>=3.9 |
license | Apache 2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# shipyard-bigquery
The `shipyard-bigquery` Python package is a local client for connecting to BigQuery to perform common operations such as loading and unloading data.
## Installation
```bash
python3 -m pip install shipyard-bigquery
```
## Usage
To initialize the client, provide the service account (in JSON format) as a string:
```python
import os
from shipyard_bigquery import BigQueryClient
service_account = os.getenv('GOOGLE_APPLICATION_CREDENTIALS') # in this case, service account is stored as an environment variable
client = BigQueryClient(service_account)
client.connect()
```
#### Upload a file to a table in BigQuery
The upload method allows for the loading of a local CSV file to BigQuery and supports two different types of upload: `overwrite` and `append`.
```python
client.upload(file = "my_file.csv", dataset = "my_dataset", table = "my_table", upload_type = 'overwrite')
```
Additionally, a the schema of the file to be loaded can be decalred ahead of time, otherwise they will be infered
```python
schema = '[{"name": "string_col", "type": "string"}, {"name": "char_col", "type": "string"}, {"name": "int_col", "type": "Int64"}, {"name": "float_col", "type": "Float64"}, {"name": "bool_col", "type": "Bool"}, {"name": "date_col", "type": "Date"},{"name": "datetime_col", "type": "Datetime"}]'
client.upload(file = "my_file.csv", dataset = "my_dataset", table = "my_table", upload_type = 'overwrite',schema = schema)
```
#### Fetch Query Results
The fetch method allows for the downloading of a SQL query to a pandas dataframe
```python
df = client.fetch('select * from my_table limit 10')
```
#### Execute Remote Queries
The execute method allows for you to execute queries without return values in BigQuery. Common operations would be dropping tables, deleting tables, or altering tables
```python
client.execute_query('drop table if exists my_table')
```
Raw data
{
"_id": null,
"home_page": null,
"name": "shipyard-bigquery",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "wrp801",
"author_email": "wespoulsen@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/6b/eb/9ea41334b592af8aa3001debfdfb0ae61632838b9ad7a30aaafb63c12f44/shipyard_bigquery-0.1.4.tar.gz",
"platform": null,
"description": "# shipyard-bigquery\n\nThe `shipyard-bigquery` Python package is a local client for connecting to BigQuery to perform common operations such as loading and unloading data.\n\n## Installation \n\n```bash\npython3 -m pip install shipyard-bigquery\n```\n\n## Usage \n\nTo initialize the client, provide the service account (in JSON format) as a string:\n```python\nimport os\nfrom shipyard_bigquery import BigQueryClient \nservice_account = os.getenv('GOOGLE_APPLICATION_CREDENTIALS') # in this case, service account is stored as an environment variable\nclient = BigQueryClient(service_account)\nclient.connect()\n```\n\n#### Upload a file to a table in BigQuery\n\n\nThe upload method allows for the loading of a local CSV file to BigQuery and supports two different types of upload: `overwrite` and `append`. \n```python\nclient.upload(file = \"my_file.csv\", dataset = \"my_dataset\", table = \"my_table\", upload_type = 'overwrite')\n```\n\nAdditionally, a the schema of the file to be loaded can be decalred ahead of time, otherwise they will be infered\n```python \nschema = '[{\"name\": \"string_col\", \"type\": \"string\"}, {\"name\": \"char_col\", \"type\": \"string\"}, {\"name\": \"int_col\", \"type\": \"Int64\"}, {\"name\": \"float_col\", \"type\": \"Float64\"}, {\"name\": \"bool_col\", \"type\": \"Bool\"}, {\"name\": \"date_col\", \"type\": \"Date\"},{\"name\": \"datetime_col\", \"type\": \"Datetime\"}]'\nclient.upload(file = \"my_file.csv\", dataset = \"my_dataset\", table = \"my_table\", upload_type = 'overwrite',schema = schema)\n```\n\n#### Fetch Query Results\nThe fetch method allows for the downloading of a SQL query to a pandas dataframe\n```python \ndf = client.fetch('select * from my_table limit 10')\n```\n\n#### Execute Remote Queries\nThe execute method allows for you to execute queries without return values in BigQuery. Common operations would be dropping tables, deleting tables, or altering tables\n\n```python \nclient.execute_query('drop table if exists my_table')\n```\n\n\n\n\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "A local client for connecting to and working with Google BigQuery",
"version": "0.1.4",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e3fb84c9c9d963481fad86de38cee07ddbdaaabe25f971f383959835e628d469",
"md5": "10916ac3726b425c1c2cf143dd362b31",
"sha256": "410fe071201dc20c6ad1735480bcd2ce1534886d25898ce88a95a5d020e91716"
},
"downloads": -1,
"filename": "shipyard_bigquery-0.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "10916ac3726b425c1c2cf143dd362b31",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 9896,
"upload_time": "2024-03-21T19:55:13",
"upload_time_iso_8601": "2024-03-21T19:55:13.770192Z",
"url": "https://files.pythonhosted.org/packages/e3/fb/84c9c9d963481fad86de38cee07ddbdaaabe25f971f383959835e628d469/shipyard_bigquery-0.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6beb9ea41334b592af8aa3001debfdfb0ae61632838b9ad7a30aaafb63c12f44",
"md5": "91dbf3db788a1b88923c76ae325ab85a",
"sha256": "33e0c6a1b68699978bff5d3a1ac19714e69323811a5e8bfc28c7a8a450817669"
},
"downloads": -1,
"filename": "shipyard_bigquery-0.1.4.tar.gz",
"has_sig": false,
"md5_digest": "91dbf3db788a1b88923c76ae325ab85a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 7107,
"upload_time": "2024-03-21T19:55:15",
"upload_time_iso_8601": "2024-03-21T19:55:15.495390Z",
"url": "https://files.pythonhosted.org/packages/6b/eb/9ea41334b592af8aa3001debfdfb0ae61632838b9ad7a30aaafb63c12f44/shipyard_bigquery-0.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-21 19:55:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "shipyard-bigquery"
}