garlic 🧄
cli and python interface for interacting with Snowflake
Features
- run queries against snowflake using simple UX
- auto-convert query results to polars dataframes
- convenience functions for:
- formatting timestamps for use in SQL queries
- setting the context (warehouse, database, schema, role)
- listing catalog of databases, schemas, tables, and query history
- creating tables from select queries
Installation
uv add paradigm_garlic
Credentials
To use garlic without giving your credentials each time, add your credentials the SNOWFLAKE_CREDENTIALS environment variable
export SNOWFLAKE_CREDENTIALS='<JSON_CREDENTIALS>'
Where <JSON_CREDENTIALS> is a JSON-encoded map of credentials
For example, if using a programmatic access key:
{
"account": "abc12345.xy12345",
"user": "my_username",
"authenticator": "PROGRAMMATIC_ACCESS_KEY",
"token": "<YOUR_PROGRAMMATIC_ACCESS_TOKEN>"
}
Alternatively, can set the credentials env var in a live python session:
os.environ['SNOWFLAKE_CREDENTIALS'] = json.dumps(credentials_dict)
Or specify the credentials in each function call:
import garlic
results = garlic.query('SELECT * FROM my_table', credentials=credentials_dict)
Example Usage
Simplest example
import garlic
dataframe = garlic.query('SELECT * FROM my_table')
Set different default warehouse:
import garlic
garlic.use_warehouse('BIG_WAREHOUSE')
dataframe = garlic.query('SELECT * FROM my_table')
Read from Snowflake management tables
import garlic
databases = garlic.list_databases()
schemas = garlic.list_schemas()
tables = garlic.list_tables()
query_history = garlic.list_query_history()
Use timestamps in CLI queries
import garlic
import datetime
sql = """
SELECT *
FROM my_table
WHERE
block_timestamp >= {start_time}
AND block_timestamp < {end_time}
""".format(
start_time=garlic.format_timestamp('2024-01-01'),
end_time=garlic.format_timestamp(datetime.datetime.now()),
)
dataframe = garlic.query(sql)
Set environment context
garlic.use_warehouse('BIG_WH')
garlic.use_schema('MY_SCHEMA')
garlic.use_database('MY_DB')
garlic.use_role('MY_ROLE')
dataframe = garlic.query('SELECT * FROM my_table')
Create table from select query
import garlic
garlic.create_table(
target_table='new_table_name',
select_sql='SELECT * FROM my_table WHERE some_column = some_value',
)
Metadata
Release files for paradigm_garlic 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| paradigm_garlic-0.2.6.tar.gz | 9.3 kB | Without provenance | Details for paradigm_garlic-0.2.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| paradigm_garlic-0.2.6-py3-none-any.whl | Python 3 | none | any | Details for paradigm_garlic-0.2.6-py3-none-any.whl |
Total release size: 19.3 kB
Release files / paradigm_garlic-0.2.6.tar.gz
| Download URL | paradigm_garlic-0.2.6.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1c288723fdfffdb76edb8835ccd9b62bb4d96efe748e88f320bd7a154d570616
|
|
BLAKE2b-256 checksum How to use checksums |
9ef46545cd006a930ba8c9d72fdfa855a269785578d346f65f63d8d2bb5472dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.0
|
Release files / paradigm_garlic-0.2.6-py3-none-any.whl
| Download URL | paradigm_garlic-0.2.6-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
75374f0919a6137bba777401533ddb6a22c63dafd5d778367f991500100bf0d6
|
|
BLAKE2b-256 checksum How to use checksums |
185be97f36a69410a7274121e82b6d4f78fe9840acef94e20deab0ac50366603
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.0
|
Security for paradigm_garlic 0.2.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.