Connections
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.
- class Connection
- classmethod duckdb(**contents: LocalDataFrameRef) DuckDBConnection
Initialize a new DuckDB connection with the provided contents. Takes in a mapping of names to content data frames, which will each be loaded into a DuckDB instance as table with that name.
Content can be specified as a path to a .csv, .json, or .parquet file, a pandas DataFrame, or a list of Python records.
- classmethod bigquery( ) BigQueryConnection
Initialize a new BigQuery connection.
By default, the connection will be authenticated using the environment variable GOOGLE_APPLICATION_CREDENTIALS, according to the same logic as the BigQuery client library. https://cloud.google.com/docs/authentication/application-default-credentials
Alternatively, you can specify an explicit path to a service account JSON file using credentials_path, or use a python dictionary using credentials_info. https://github.com/googleapis/python-bigquery-sqlalchemy?tab=readme-ov-file#authentication
- classmethod postgres(
- *,
- host: str,
- port: str = '5432',
- user: str,
- password: str,
- database: str,
- default_schema: str | None = None,
Initialize a new Postgres connection.
The default port is 5432.
- classmethod snowflake(
- *,
- account: str,
- user: str,
- database: str,
- default_schema: str | None = None,
- warehouse: str,
- role: str,
- password: str | None = None,
- private_key: str | None = None,
- encryption_passphrase: str | None = None,
Initialize a new Snowflake connection.
Credentials may be specified via password or key-pair authentication. If key-pair authentication is used, private_key must be specified and encryption_passphrase may optionally be provided. https://docs.snowflake.com/en/user-guide/key-pair-auth
- run_reflection(
- *,
- include_views: bool = True,
- include_columns: bool = True,
- include_column_descriptions: bool = False,
Run reflection on this connection, gathering up information about all the available tables and views.
This can be a slow operation, particularly for databases with lots of wide tables. You can omit columns from the reflection with include_columns=False. You can omit views from the reflection with include_views=False. You can omit column descriptions from the reflection with include_column_descriptions=False.
To run a reflection on a single table or view, use run_table_reflection.
Connections store secrets in a special wrapped Secret
value and are never serialized or sent across network boundaries.