Metadata-Version: 2.4
Name: paradigm_garlic
Version: 0.2.2
Summary: garlic is a cli and python interface for Allium data
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Requires-Dist: pandas>=2.3.1
Requires-Dist: polars >= 1.0
Requires-Dist: pyarrow<19.0.0
Requires-Dist: snowflake-connector-python >= 3.15.0
Requires-Dist: tooltime>=0.3.4
Requires-Dist: typing-extensions >=4.9.0 ; extra == "test"
Project-URL: Documentation, https://github.com/paradigmxyz/garlic
Project-URL: Source, https://github.com/paradigmxyz/garlic
Provides-Extra: test


# 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

```bash
uv add paradigm_garlic
```

## Example Usage

#### Simplest example
```python
import garlic

dataframe = garlic.query('SELECT * FROM my_table')
```

#### Set different default warehouse:
```python
import garlic

garlic.use_warehouse('BIG_WAREHOUSE')
dataframe = garlic.query('SELECT * FROM my_table')
```

#### Read from Snowflake management tables

```python
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

```python
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

```python
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

```python
import garlic

garlic.create_table(
    target_table='new_table_name',
    select_sql='SELECT * FROM my_table WHERE some_column = some_value',
)
```

