sqlspec 0.20.0__tar.gz → 0.21.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sqlspec might be problematic. Click here for more details.
- {sqlspec-0.20.0 → sqlspec-0.21.1}/PKG-INFO +230 -44
- {sqlspec-0.20.0 → sqlspec-0.21.1}/README.md +229 -43
- {sqlspec-0.20.0 → sqlspec-0.21.1}/pyproject.toml +6 -5
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/mixins/_result_tools.py +41 -6
- sqlspec-0.21.1/sqlspec/extensions/litestar/config.py +276 -0
- sqlspec-0.21.1/sqlspec/extensions/litestar/plugin.py +386 -0
- sqlspec-0.21.1/sqlspec/utils/data_transformation.py +120 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/text.py +27 -19
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/type_guards.py +74 -0
- sqlspec-0.21.1/tests/unit/test_extensions/__init__.py +1 -0
- sqlspec-0.21.1/tests/unit/test_extensions/test_litestar/__init__.py +1 -0
- sqlspec-0.21.1/tests/unit/test_extensions/test_litestar/test_config.py +482 -0
- sqlspec-0.21.1/tests/unit/test_utils/test_data_transformation.py +343 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_text.py +1 -36
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_type_guards.py +105 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/uv.lock +247 -219
- sqlspec-0.20.0/sqlspec/extensions/litestar/config.py +0 -92
- sqlspec-0.20.0/sqlspec/extensions/litestar/plugin.py +0 -152
- {sqlspec-0.20.0 → sqlspec-0.21.1}/.gitignore +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/.pre-commit-config.yaml +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/CONTRIBUTING.rst +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/LICENSE +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/Makefile +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/NOTICE +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/__main__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/__metadata__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/_serialization.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/_sql.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/_typing.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/adbc/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/adbc/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/adbc/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/adbc/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/aiosqlite/pool.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncmy/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncmy/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncmy/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncmy/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncpg/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncpg/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncpg/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/asyncpg/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/bigquery/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/bigquery/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/bigquery/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/bigquery/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/duckdb/pool.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/oracledb/migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psqlpy/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psqlpy/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psqlpy/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psqlpy/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psycopg/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psycopg/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psycopg/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/psycopg/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/_types.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/adapters/sqlite/pool.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/base.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_base.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_column.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_ddl.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_delete.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_expression_wrappers.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_insert.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_merge.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_parsing_utils.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_select.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/_update.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_cte_and_set_ops.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_delete_operations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_insert_operations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_join_operations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_merge_operations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_order_limit_operations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_pivot_operations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_select_operations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_update_operations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/builder/mixins/_where_clause.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/cli.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/cache.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/compiler.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/filters.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/hashing.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/parameters.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/result.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/splitter.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/core/statement.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/_async.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/_common.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/_sync.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/mixins/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/driver/mixins/_sql_translator.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/exceptions.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/aiosql/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/aiosql/adapter.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/_utils.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/cli.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/handlers.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/extensions/litestar/providers.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/loader.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/base.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/commands.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/loaders.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/runner.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/tracker.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/migrations/utils.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/protocols.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/py.typed +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/backends/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/backends/base.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/backends/fsspec.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/backends/obstore.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/capabilities.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/storage/registry.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/typing.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/correlation.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/deprecation.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/fixtures.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/logging.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/module_loader.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/serializers.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/singleton.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/sqlspec/utils/sync_tools.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/asset_maintenance.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/ddls-mysql-collection.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/ddls-postgres-collection.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/example_usage.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/init.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-config.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-data_types.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-database_details.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-engines.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-hostname.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-plugins.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-process_list.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-resource-groups.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-schema_objects.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-table_details.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/collection-users.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/mysql/init.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/oracle.ddl.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-applications.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-aws_extension_dependency.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-aws_oracle_exists.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-bg_writer_stats.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-calculated_metrics.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-data_types.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-database_details.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-extensions.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-index_details.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-pglogical-details.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-privileges.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-replication_slots.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-replication_stats.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-schema_details.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-schema_objects.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-settings.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-source_details.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/collection-table_details.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/extended-collection-all-databases.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/postgres/init.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/readiness-check.sql +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/fixtures/sql_utils.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_arrow_features.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_backends.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_connection.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_edge_cases.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_adbc_results.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_adbc/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_connection.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_aiosqlite/test_pooling.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_asyncmy_features.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncmy/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_connection.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_execute_many.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_asyncpg/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/test_bigquery_features.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/test_config.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/test_connection.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_bigquery/test_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_connection.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_execute_many.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_mixed_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/test_pooling.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_duckdb/utils.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_connection.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_driver_async.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_driver_sync.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_execute_many.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_oracle_features.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_oracledb/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_connection.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psqlpy/test_psqlpy_features.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_async_copy.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_connection.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_execute_many.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_psycopg/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_driver.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_migrations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_parameter_styles.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_pooling.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_adapters/test_sqlite/test_query_mixin.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_loader/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_loader/test_file_system_loading.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/integration/test_migrations/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/conftest.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/test_adapter_implementations.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/test_async_adapters.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_adapters/test_sync_adapters.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_base/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_base/test_sql_integration.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_base/test_sqlspec_class.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_builder/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_builder/test_insert_builder.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_builder/test_parameter_naming.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_builder_parameter_naming.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_cache.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_compiler.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_filters.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_hashing.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_parameters.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_result.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_core/test_statement.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/test_cache_integration.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/test_fixtures_directory_loading.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/test_loading_patterns.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_loader/test_sql_file_loader.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/test_migration.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/test_migration_commands.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/test_migration_execution.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_migrations/test_migration_runner.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_parsing_utils.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_sql_factory.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_correlation.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_deprecation.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_fixtures.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_logging.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_module_loader.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_serializers.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_singleton.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tests/unit/test_utils/test_sync_tools.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/build_docs.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/local-infra.sh +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/pypi_readme.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/sphinx_ext/__init__.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/sphinx_ext/changelog.py +0 -0
- {sqlspec-0.20.0 → sqlspec-0.21.1}/tools/sphinx_ext/missing_references.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlspec
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.21.1
|
|
4
4
|
Summary: SQL Experiments in Python
|
|
5
5
|
Project-URL: Discord, https://discord.gg/litestar
|
|
6
6
|
Project-URL: Issue, https://github.com/litestar-org/sqlspec/issues/
|
|
@@ -130,16 +130,21 @@ These are just a few examples that demonstrate SQLSpec's flexibility. Each of th
|
|
|
130
130
|
```python
|
|
131
131
|
from sqlspec import SQLSpec
|
|
132
132
|
from sqlspec.adapters.sqlite import SqliteConfig
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
# Create SQLSpec instance and configure database
|
|
135
|
-
|
|
136
|
-
config =
|
|
135
|
+
db_manager = SQLSpec()
|
|
136
|
+
config = SqliteConfig(pool_config={"database": ":memory:"}) # Thread local pooling
|
|
137
|
+
db_manager.add_config(config)
|
|
137
138
|
|
|
138
139
|
# Execute queries with automatic result mapping
|
|
139
|
-
with
|
|
140
|
+
with db_manager.provide_session(config) as session:
|
|
140
141
|
# Simple query
|
|
141
142
|
result = session.execute("SELECT 'Hello, SQLSpec!' as message")
|
|
142
143
|
print(result.get_first()) # {'message': 'Hello, SQLSpec!'}
|
|
144
|
+
|
|
145
|
+
# Type-safe single row query
|
|
146
|
+
row = session.select_one("SELECT 'Hello, SQLSpec!' as message")
|
|
147
|
+
print(row) # {'message': 'Hello, SQLSpec!'}
|
|
143
148
|
```
|
|
144
149
|
|
|
145
150
|
### SQL Builder Example (Experimental)
|
|
@@ -150,30 +155,94 @@ with sql.provide_session(config) as session:
|
|
|
150
155
|
from sqlspec import sql
|
|
151
156
|
|
|
152
157
|
# Build a simple query
|
|
153
|
-
query = sql.select("id", "name", "email").from_("users").where("active = ?"
|
|
154
|
-
|
|
158
|
+
query = sql.select("id", "name", "email").from_("users").where("active = ?")
|
|
159
|
+
statement = query.to_statement()
|
|
160
|
+
print(statement.sql) # SELECT id, name, email FROM users WHERE active = ?
|
|
155
161
|
|
|
156
162
|
# More complex example with joins
|
|
157
163
|
query = (
|
|
158
164
|
sql.select("u.name", "COUNT(o.id) as order_count")
|
|
159
165
|
.from_("users u")
|
|
160
166
|
.left_join("orders o", "u.id = o.user_id")
|
|
161
|
-
.where("u.created_at > ?"
|
|
167
|
+
.where("u.created_at > ?")
|
|
162
168
|
.group_by("u.name")
|
|
163
|
-
.having("COUNT(o.id) > ?"
|
|
169
|
+
.having("COUNT(o.id) > ?")
|
|
164
170
|
.order_by("order_count", desc=True)
|
|
165
171
|
)
|
|
166
172
|
|
|
167
|
-
# Execute the built query
|
|
168
|
-
with
|
|
169
|
-
results = session.execute(query
|
|
173
|
+
# Execute the built query with parameters
|
|
174
|
+
with db_manager.provide_session(config) as session:
|
|
175
|
+
results = session.execute(query, "2024-01-01", 5)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Type-Safe Result Mapping
|
|
179
|
+
|
|
180
|
+
SQLSpec supports automatic mapping to typed models using popular libraries:
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from sqlspec import SQLSpec
|
|
184
|
+
from sqlspec.adapters.sqlite import SqliteConfig
|
|
185
|
+
from pydantic import BaseModel
|
|
186
|
+
|
|
187
|
+
class User(BaseModel):
|
|
188
|
+
id: int
|
|
189
|
+
name: str
|
|
190
|
+
email: str
|
|
191
|
+
|
|
192
|
+
db_manager = SQLSpec()
|
|
193
|
+
config = SqliteConfig(pool_config={"database": ":memory:"})
|
|
194
|
+
db_manager.add_config(config)
|
|
195
|
+
|
|
196
|
+
with db_manager.provide_session(config) as session:
|
|
197
|
+
# Create and populate test data
|
|
198
|
+
session.execute_script("""
|
|
199
|
+
CREATE TABLE users (id INTEGER, name TEXT, email TEXT);
|
|
200
|
+
INSERT INTO users VALUES (1, 'Alice', 'alice@example.com');
|
|
201
|
+
""")
|
|
202
|
+
# Map single result to typed model
|
|
203
|
+
user = session.select_one("SELECT * FROM users WHERE id = ?", 1, schema_type=User)
|
|
204
|
+
print(f"User: {user.name} ({user.email})")
|
|
205
|
+
|
|
206
|
+
# Map multiple results
|
|
207
|
+
users = session.select("SELECT * FROM users", schema_type=User)
|
|
208
|
+
for user in users:
|
|
209
|
+
print(f"User: {user.name}")
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Session Methods Overview
|
|
213
|
+
|
|
214
|
+
SQLSpec provides several convenient methods for executing queries:
|
|
215
|
+
|
|
216
|
+
```python
|
|
217
|
+
with db_manager.provide_session(config) as session:
|
|
218
|
+
# Execute any SQL and get full result set
|
|
219
|
+
result = session.execute("SELECT * FROM users")
|
|
220
|
+
|
|
221
|
+
# Get single row (raises error if not found)
|
|
222
|
+
user = session.select_one("SELECT * FROM users WHERE id = ?", 1)
|
|
223
|
+
|
|
224
|
+
# Get single row or None (no error if not found)
|
|
225
|
+
maybe_user = session.select_one_or_none("SELECT * FROM users WHERE id = ?", 999)
|
|
226
|
+
|
|
227
|
+
# Execute with many parameter sets (bulk operations)
|
|
228
|
+
session.execute_many(
|
|
229
|
+
"INSERT INTO users (name, email) VALUES (?, ?)",
|
|
230
|
+
[("Bob", "bob@example.com"), ("Carol", "carol@example.com")]
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
# Execute multiple statements as a script
|
|
234
|
+
session.execute_script("""
|
|
235
|
+
CREATE TABLE IF NOT EXISTS logs (id INTEGER, message TEXT);
|
|
236
|
+
INSERT INTO logs (message) VALUES ('System started');
|
|
237
|
+
""")
|
|
170
238
|
```
|
|
171
239
|
|
|
172
|
-
|
|
240
|
+
<details>
|
|
241
|
+
<summary>🦆 DuckDB LLM Integration Example</summary>
|
|
173
242
|
|
|
174
243
|
This is a quick implementation using some of the built-in Secret and Extension management features of SQLSpec's DuckDB integration.
|
|
175
244
|
|
|
176
|
-
It allows you to communicate with any compatible
|
|
245
|
+
It allows you to communicate with any compatible OpenAI conversations endpoint (such as Ollama). This example:
|
|
177
246
|
|
|
178
247
|
- auto installs the `open_prompt` DuckDB extensions
|
|
179
248
|
- automatically creates the correct `open_prompt` compatible secret required to use the extension
|
|
@@ -193,11 +262,12 @@ from pydantic import BaseModel
|
|
|
193
262
|
class ChatMessage(BaseModel):
|
|
194
263
|
message: str
|
|
195
264
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
265
|
+
db_manager = SQLSpec()
|
|
266
|
+
config = DuckDBConfig(
|
|
267
|
+
pool_config={"database": ":memory:"},
|
|
268
|
+
driver_features={
|
|
269
|
+
"extensions": [{"name": "open_prompt"}],
|
|
270
|
+
"secrets": [
|
|
201
271
|
{
|
|
202
272
|
"secret_type": "open_prompt",
|
|
203
273
|
"name": "open_prompt",
|
|
@@ -208,9 +278,11 @@ etl_config = sql.add_config(
|
|
|
208
278
|
},
|
|
209
279
|
}
|
|
210
280
|
],
|
|
211
|
-
|
|
281
|
+
},
|
|
212
282
|
)
|
|
213
|
-
|
|
283
|
+
db_manager.add_config(config)
|
|
284
|
+
|
|
285
|
+
with db_manager.provide_session(config) as session:
|
|
214
286
|
result = session.select_one(
|
|
215
287
|
"SELECT open_prompt(?)",
|
|
216
288
|
"Can you write a haiku about DuckDB?",
|
|
@@ -219,7 +291,10 @@ with sql.provide_session(etl_config) as session:
|
|
|
219
291
|
print(result) # result is a ChatMessage pydantic model
|
|
220
292
|
```
|
|
221
293
|
|
|
222
|
-
|
|
294
|
+
</details>
|
|
295
|
+
|
|
296
|
+
<details>
|
|
297
|
+
<summary>🔗 DuckDB Gemini Embeddings Example</summary>
|
|
223
298
|
|
|
224
299
|
In this example, we are again using DuckDB. However, we are going to use the built-in to call the Google Gemini embeddings service directly from the database.
|
|
225
300
|
|
|
@@ -246,11 +321,12 @@ API_URL = (
|
|
|
246
321
|
f"https://generativelanguage.googleapis.com/v1beta/models/{EMBEDDING_MODEL}:embedContent?key=${GOOGLE_API_KEY}"
|
|
247
322
|
)
|
|
248
323
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
324
|
+
db_manager = SQLSpec()
|
|
325
|
+
config = DuckDBConfig(
|
|
326
|
+
pool_config={"database": ":memory:"},
|
|
327
|
+
driver_features={
|
|
328
|
+
"extensions": [{"name": "vss"}, {"name": "http_client"}],
|
|
329
|
+
"on_connection_create": lambda connection: connection.execute(f"""
|
|
254
330
|
CREATE IF NOT EXISTS MACRO generate_embedding(q) AS (
|
|
255
331
|
WITH __request AS (
|
|
256
332
|
SELECT http_post(
|
|
@@ -269,16 +345,77 @@ etl_config = sql.add_config(
|
|
|
269
345
|
FROM __request,
|
|
270
346
|
);
|
|
271
347
|
"""),
|
|
272
|
-
|
|
348
|
+
},
|
|
273
349
|
)
|
|
274
|
-
|
|
350
|
+
db_manager.add_config(config)
|
|
351
|
+
|
|
352
|
+
with db_manager.provide_session(config) as session:
|
|
275
353
|
result = session.execute("SELECT generate_embedding('example text')")
|
|
276
354
|
print(result.get_first()) # result is a dictionary when `schema_type` is omitted.
|
|
277
355
|
```
|
|
278
356
|
|
|
357
|
+
</details>
|
|
358
|
+
|
|
359
|
+
### SQL File Loading
|
|
360
|
+
|
|
361
|
+
SQLSpec can load and manage SQL queries from files using aiosql-style named queries:
|
|
362
|
+
|
|
363
|
+
```python
|
|
364
|
+
from sqlspec import SQLSpec
|
|
365
|
+
from sqlspec.loader import SQLFileLoader
|
|
366
|
+
from sqlspec.adapters.sqlite import SqliteConfig
|
|
367
|
+
|
|
368
|
+
# Initialize with SQL file loader
|
|
369
|
+
db_manager = SQLSpec(loader=SQLFileLoader())
|
|
370
|
+
config = SqliteConfig(pool_config={"database": ":memory:"})
|
|
371
|
+
db_manager.add_config(config)
|
|
372
|
+
|
|
373
|
+
# Load SQL files from directory
|
|
374
|
+
db_manager.load_sql_files("./sql")
|
|
375
|
+
|
|
376
|
+
# SQL file: ./sql/users.sql
|
|
377
|
+
# -- name: get_user
|
|
378
|
+
# SELECT * FROM users WHERE id = ?
|
|
379
|
+
#
|
|
380
|
+
# -- name: create_user
|
|
381
|
+
# INSERT INTO users (name, email) VALUES (?, ?)
|
|
382
|
+
|
|
383
|
+
with db_manager.provide_session(config) as session:
|
|
384
|
+
# Use named queries from files
|
|
385
|
+
user = session.execute(db_manager.get_sql("get_user"), 1)
|
|
386
|
+
session.execute(db_manager.get_sql("create_user"), "Alice", "alice@example.com")
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### Database Migrations
|
|
390
|
+
|
|
391
|
+
SQLSpec includes a built-in migration system for managing schema changes. After configuring your database with migration settings, use the CLI commands:
|
|
392
|
+
|
|
393
|
+
```bash
|
|
394
|
+
# Initialize migration directory
|
|
395
|
+
sqlspec db init migrations
|
|
396
|
+
|
|
397
|
+
# Generate new migration file
|
|
398
|
+
sqlspec db make-migrations "Add user table"
|
|
399
|
+
|
|
400
|
+
# Apply all pending migrations
|
|
401
|
+
sqlspec db upgrade
|
|
402
|
+
|
|
403
|
+
# Show current migration status
|
|
404
|
+
sqlspec db show-current-revision
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
For Litestar applications, replace `sqlspec` with your application command:
|
|
408
|
+
|
|
409
|
+
```bash
|
|
410
|
+
# Using Litestar CLI integration
|
|
411
|
+
litestar db make-migrations "Add user table"
|
|
412
|
+
litestar db upgrade
|
|
413
|
+
litestar db show-current-revision
|
|
414
|
+
```
|
|
415
|
+
|
|
279
416
|
### Basic Litestar Integration
|
|
280
417
|
|
|
281
|
-
In this example we
|
|
418
|
+
In this example we demonstrate how to create a basic configuration that integrates into Litestar:
|
|
282
419
|
|
|
283
420
|
```py
|
|
284
421
|
# /// script
|
|
@@ -301,7 +438,7 @@ async def simple_sqlite(db_session: AiosqliteDriver) -> dict[str, str]:
|
|
|
301
438
|
|
|
302
439
|
sqlspec = SQLSpec(
|
|
303
440
|
config=DatabaseConfig(
|
|
304
|
-
config=AiosqliteConfig(),
|
|
441
|
+
config=AiosqliteConfig(pool_config={"database": ":memory:"}), # built in local pooling
|
|
305
442
|
commit_mode="autocommit"
|
|
306
443
|
)
|
|
307
444
|
)
|
|
@@ -320,6 +457,41 @@ The primary goal at this stage is to establish a **native connectivity interface
|
|
|
320
457
|
|
|
321
458
|
This list is not final. If you have a driver you'd like to see added, please open an issue or submit a PR!
|
|
322
459
|
|
|
460
|
+
### Configuration Examples
|
|
461
|
+
|
|
462
|
+
Each adapter uses a consistent configuration pattern with `pool_config` for connection parameters:
|
|
463
|
+
|
|
464
|
+
```python
|
|
465
|
+
# SQLite
|
|
466
|
+
SqliteConfig(pool_config={"database": "/path/to/database.db"})
|
|
467
|
+
AiosqliteConfig(pool_config={"database": "/path/to/database.db"}) # Async
|
|
468
|
+
AdbcConfig(connection_config={"uri": "sqlite:///path/to/database.db"}) # ADBC
|
|
469
|
+
|
|
470
|
+
# PostgreSQL (multiple drivers available)
|
|
471
|
+
PsycopgSyncConfig(pool_config={"host": "localhost", "database": "mydb", "user": "user", "password": "pass"})
|
|
472
|
+
PsycopgAsyncConfig(pool_config={"host": "localhost", "database": "mydb", "user": "user", "password": "pass"}) # Async
|
|
473
|
+
AsyncpgConfig(pool_config={"host": "localhost", "database": "mydb", "user": "user", "password": "pass"})
|
|
474
|
+
PsqlpyConfig(pool_config={"dsn": "postgresql://user:pass@localhost/mydb"})
|
|
475
|
+
AdbcConfig(connection_config={"uri": "postgresql://user:pass@localhost/mydb"}) # ADBC
|
|
476
|
+
|
|
477
|
+
# DuckDB
|
|
478
|
+
DuckDBConfig(pool_config={"database": ":memory:"}) # or file path
|
|
479
|
+
AdbcConfig(connection_config={"uri": "duckdb:///path/to/database.duckdb"}) # ADBC
|
|
480
|
+
|
|
481
|
+
# MySQL
|
|
482
|
+
AsyncmyConfig(pool_config={"host": "localhost", "database": "mydb", "user": "user", "password": "pass"}) # Async
|
|
483
|
+
|
|
484
|
+
# Oracle
|
|
485
|
+
OracleSyncConfig(pool_config={"host": "localhost", "service_name": "XEPDB1", "user": "user", "password": "pass"})
|
|
486
|
+
OracleAsyncConfig(pool_config={"host": "localhost", "service_name": "XEPDB1", "user": "user", "password": "pass"}) # Async
|
|
487
|
+
|
|
488
|
+
# BigQuery
|
|
489
|
+
BigQueryConfig(pool_config={"project": "my-project", "dataset": "my_dataset"})
|
|
490
|
+
AdbcConfig(connection_config={"driver_name": "adbc_driver_bigquery", "project_id": "my-project", "dataset_id": "my_dataset"}) # ADBC
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### Supported Drivers
|
|
494
|
+
|
|
323
495
|
| Driver | Database | Mode | Status |
|
|
324
496
|
| :----------------------------------------------------------------------------------------------------------- | :--------- | :------ | :--------- |
|
|
325
497
|
| [`adbc`](https://arrow.apache.org/adbc/) | Postgres | Sync | ✅ |
|
|
@@ -342,21 +514,35 @@ This list is not final. If you have a driver you'd like to see added, please ope
|
|
|
342
514
|
| [`asyncmy`](https://github.com/long2ice/asyncmy) | MySQL | Async | ✅ |
|
|
343
515
|
| [`snowflake`](https://docs.snowflake.com) | Snowflake | Sync | 🗓️ |
|
|
344
516
|
|
|
345
|
-
##
|
|
517
|
+
## Project Structure
|
|
346
518
|
|
|
347
519
|
- `sqlspec/`:
|
|
348
|
-
- `adapters/`:
|
|
349
|
-
- `extensions/`:
|
|
350
|
-
- `litestar/`: Litestar framework integration ✅
|
|
351
|
-
- `
|
|
352
|
-
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
- `
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
520
|
+
- `adapters/`: Database-specific drivers and configuration classes for all supported databases
|
|
521
|
+
- `extensions/`: Framework integrations and external library adapters
|
|
522
|
+
- `litestar/`: Litestar web framework integration with dependency injection ✅
|
|
523
|
+
- `aiosql/`: Integration with aiosql for SQL file loading ✅
|
|
524
|
+
- Future integrations: `fastapi/`, `flask/`, etc.
|
|
525
|
+
- `builder/`: Fluent SQL query builder with method chaining and type safety
|
|
526
|
+
- `mixins/`: Composable query building operations (WHERE, JOIN, ORDER BY, etc.)
|
|
527
|
+
- `core/`: Core query processing infrastructure
|
|
528
|
+
- `statement.py`: SQL statement wrapper with metadata and type information
|
|
529
|
+
- `parameters.py`: Parameter style conversion and validation
|
|
530
|
+
- `result.py`: Result set handling and type mapping
|
|
531
|
+
- `compiler.py`: SQL compilation and validation using SQLGlot
|
|
532
|
+
- `cache.py`: Statement caching for performance optimization
|
|
533
|
+
- `driver/`: Base driver system with sync/async support and transaction management
|
|
534
|
+
- `mixins/`: Shared driver capabilities (result processing, SQL translation)
|
|
535
|
+
- `migrations/`: Database migration system with CLI commands
|
|
536
|
+
- `storage/`: Unified data import/export operations with multiple backends
|
|
537
|
+
- `backends/`: Storage backend implementations (fsspec, obstore)
|
|
538
|
+
- `utils/`: Utility functions, type guards, and helper tools
|
|
539
|
+
- `base.py`: Main SQLSpec registry and configuration manager
|
|
540
|
+
- `loader.py`: SQL file loading system for `.sql` files
|
|
541
|
+
- `cli.py`: Command-line interface for migrations and database operations
|
|
542
|
+
- `config.py`: Base configuration classes and protocols
|
|
543
|
+
- `protocols.py`: Type protocols for runtime type checking
|
|
544
|
+
- `exceptions.py`: Custom exception hierarchy for SQLSpec
|
|
545
|
+
- `typing.py`: Type definitions, guards, and optional dependency facades
|
|
360
546
|
|
|
361
547
|
## Get Involved
|
|
362
548
|
|