Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shipyard_motherduck-0.1.2.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

shipyard_motherduck-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file shipyard_motherduck-0.1.2.tar.gz.

File metadata

  • Download URL: shipyard_motherduck-0.1.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.9.18 Darwin/23.2.0

File hashes

Hashes for shipyard_motherduck-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3e2d9052c4d7b73c1734c9b8254672b00d54929c33c7b6014ca33fb55be00c31
MD5 7020e070b9b1957f6b21ab8a53e737ce
BLAKE2b-256 0bc00d0f327a94453638a2a3d0a8264f2dd0474bd3aeefe3fc201dc74e032e14

See more details on using hashes here.

File details

Details for the file shipyard_motherduck-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for shipyard_motherduck-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3632f8e3722d1f832f9a8739292700e49105090421a000c37787ae141073d437
MD5 f373cdf1192b4525538cb775ceb56723
BLAKE2b-256 d3ba583df3f814282a870040baa403647f1b4df0db5780935788d3d22a6c2fd1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page