A local client for working with Python and MotherDuck
Project description
shipyard-motherduck
Installation
python3 -m pip install shipyard-motherduck
Usage
In order to initalize the client, pass the access token to the MotherDuckClient
object:
client = MotherDuckClient("<access_token>")
Additionally you can connect to a specifc database by supplying the database to the client:
client = MotherDuckClient("<access_token>", database = 'my_db')
Loading Data
The upload
method allows for a quick upload of a file to a table in MotherDuck. If the table does not exist,
it will be created. The target table can also be appended to by setting the insert_method
to 'append'.
Example:
client.upload(table_name = 'my_new_table', file_path = 'my_data.csv', insert_method = 'replace')
Fetching Data
The fetch
method returns the results of a SQL query as a DuckDBPyRelation
type. From there, it can be converted to a DataFrame or
written to a file.
Example:
results = client.fetch('select * from my_new_table')
df = results.to_df()
Executing a Query
The execute_query
method executes a SQL query in MotherDuck. The difference between this and the fetch
method is that this
does not return results and is intended for ALTER, CREATE, DROP
and other DDL queries.
Example:
client.execute_query('DROP TABLE my_new_table')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for shipyard_motherduck-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c41fd7e95783f3a630bfbf702f6146d80651114074080a3d644ee84817e85d6 |
|
MD5 | 658399930f43694f0e8374e6dc35a434 |
|
BLAKE2b-256 | 639f95332a266246d5f80532be0e18abdc4189ec966770e89336eba8e17fcb21 |
Hashes for shipyard_motherduck-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99fd7a4fb32d0d876d39ead91f1590485fa2016f7b819767ad25beeef775bdf7 |
|
MD5 | 3e44d9512e81b9ceff60b3228b4244b6 |
|
BLAKE2b-256 | 396354789a3f298b88d750894e8bdd0ef657fcd4ca9ea38b66386eb3e9f0a0cf |