Skip to main content

garlic is a cli and python interface for Allium data

Project description

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

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',
)

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

paradigm_garlic-0.2.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paradigm_garlic-0.2.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file paradigm_garlic-0.2.2.tar.gz.

File metadata

  • Download URL: paradigm_garlic-0.2.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for paradigm_garlic-0.2.2.tar.gz
Algorithm Hash digest
SHA256 24089b763f288a3d4995d76299541dd25f1dd27a71c66ed61b23fa8fc6f059c6
MD5 2d57af8809e3895c662d3a0e28bdb455
BLAKE2b-256 becdb3902b710a9f686e67126622a9db03222fbea83f3b262314624e5a6e3d18

See more details on using hashes here.

File details

Details for the file paradigm_garlic-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for paradigm_garlic-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8397b1d4b05be493a59845a60376e27e79a4a75411a1dac024a9db47f4ef9013
MD5 f0f540ed7cc641863dd7ccbcb02cbda9
BLAKE2b-256 3597fa7ccd1c1741f5447ec379f13289cb720cca23e42c4ba9918e212ee70743

See more details on using hashes here.

Supported by

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