Quickstart
Attention
Hashquery is currently in public preview. Here are some caveats to keep in mind for early adopters:
Backwards compatibility may not be preserved between version upgrades, and you may need to update your package regularly.
There may be differences in the SQL logic generated by hashquery compared to the Hashboard app.
You may encounter dialect-specific SQL syntax errors or other unexpected errors. If you come across one, let us know by reporting an issue.
Installation
Hashquery is installed with pip
from PyPI. Hashquery requires Python version 3.6 or above.
The Hashquery package includes a variety of pip extras. These can be used to specify which database driver(s) you wish to install.
The following drivers are currently available for installation:
Database |
Install |
---|---|
|
|
|
|
|
For this quickstart, we’ll use [duckdb]
and just work with locally defined data frames.
pip install hashquery[duckdb]
Validate the installation
The following is a simple script which loads some mock data into a dataframe and then queries its first 2 records:
from hashquery import *
import pandas as pd
# create a new duckdb instance populated with a demo dataset
db = Connection.duckdb(
people=[
{"name": "Alice", "age": 25, "city": "New York"},
{"name": "Bob", "age": 32, "city": "New York"},
{"name": "Cassie", "age": 30, "city": "Chicago"},
{"name": "David", "age": 42, "city": "Houston"},
]
)
# create our first model, just a view over the "people" table
people = Model(db, "people")
# query the model, just grabbing the first 2 records
print(people.limit(2).run().df)
When you run this script, you should see Alice and Bob’s information echoed back to you.