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.1.tar.gz (5.2 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.1-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for paradigm_garlic-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fb3cac0c51044807f733c98379e2319290a43497a78833b1e9f862d2457eb883
MD5 2f1286e65716e7371604e37af0ec2b59
BLAKE2b-256 235af2c54af6639e8dfb5aa5769f616265bcd2acc8efabe1dc184b40f1b6e829

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for paradigm_garlic-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98bf0fbae2ed7d40ed71bb26e2ffbbfb7f7df3b05693a2e1beac8f438a887114
MD5 a9b50270d41f1b47939bfcef2ada958c
BLAKE2b-256 e5681ba6ae568e5f67c58dfa36f649a7892383a72aaa91f0b3f13065292b372b

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