nlp2sql 0.2.0rc21__tar.gz → 0.2.0rc22__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.
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.github/workflows/ci.yml +59 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/CHANGELOG.md +54 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/CONTRIBUTING.md +1 -2
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/PKG-INFO +7 -8
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/README.md +5 -1
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/SECURITY.md +9 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docker/.env.example +11 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docker/README.md +7 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docker/docker-compose.yml +40 -0
- nlp2sql-0.2.0rc22/docker/mysql/init-schema.sql +317 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docs/API.md +1 -1
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docs/ARCHITECTURE.md +3 -2
- nlp2sql-0.2.0rc22/docs/MySQL.md +139 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/mcp_server/README.md +15 -1
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/mcp_server/__init__.py +1 -1
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/mcp_server/pyproject.toml +2 -2
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/mcp_server/server.py +40 -15
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/pyproject.toml +4 -4
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/__init__.py +9 -7
- nlp2sql-0.2.0rc22/src/nlp2sql/adapters/_tables_cache.py +139 -0
- nlp2sql-0.2.0rc22/src/nlp2sql/adapters/default_error_classifier.py +147 -0
- nlp2sql-0.2.0rc22/src/nlp2sql/adapters/mysql_repository.py +548 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/postgres_repository.py +15 -137
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/redshift_adapter.py +9 -122
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/regex_query_validator.py +3 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/cli.py +16 -8
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/client.py +2 -4
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/config/settings.py +1 -1
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/database_prompts.py +27 -1
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/sql_keywords.py +29 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/sql_safety.py +151 -31
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/factories/repository_factory.py +60 -40
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/query_service.py +39 -8
- nlp2sql-0.2.0rc22/src/nlp2sql/utils/redaction.py +58 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/conftest.py +54 -0
- nlp2sql-0.2.0rc22/tests/mcp/test_database_url_in_tool_results.py +177 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cli_setup.py +4 -2
- nlp2sql-0.2.0rc22/tests/test_database_type_detection.py +110 -0
- nlp2sql-0.2.0rc22/tests/test_mysql_dialect_against_servers.py +98 -0
- nlp2sql-0.2.0rc22/tests/test_mysql_dialect_support.py +242 -0
- nlp2sql-0.2.0rc22/tests/test_mysql_repository.py +203 -0
- nlp2sql-0.2.0rc22/tests/test_mysql_repository_against_servers.py +250 -0
- nlp2sql-0.2.0rc22/tests/test_mysql_test_database.py +87 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_readonly_execution_against_postgres.py +1 -1
- nlp2sql-0.2.0rc22/tests/test_redaction.py +62 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_repository_factory.py +3 -7
- nlp2sql-0.2.0rc22/tests/test_sql_safety_mysql.py +137 -0
- nlp2sql-0.2.0rc22/tests/test_tables_cache.py +89 -0
- nlp2sql-0.2.0rc22/tests/test_unreadable_database_url.py +53 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/uv.lock +9 -173
- nlp2sql-0.2.0rc21/src/nlp2sql/adapters/default_error_classifier.py +0 -65
- nlp2sql-0.2.0rc21/src/nlp2sql/utils/redaction.py +0 -31
- nlp2sql-0.2.0rc21/tests/test_redaction.py +0 -34
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.claude/commands/db.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.claude/commands/quality.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.claude/commands/test.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.claude/rules/adapters.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.claude/rules/architecture.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.claude/rules/python-style.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.claude/rules/testing.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.claude/settings.json +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.github/pull_request_template.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.github/scripts/verify_release_tag.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.github/workflows/publish-pypi.yml +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.github/workflows/publish-testpypi.yml +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.gitignore +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.mcp.json.example +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/.python-version +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/CLAUDE.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/CODE_OF_CONDUCT.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/LICENSE +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/assets/nlp2sql-hero-dark.svg +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/assets/nlp2sql-hero-light.svg +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/benchmarks/enterprise_benchmark_results.json +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docker/get-db-urls.sh +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docker/init-schema.sql +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docker/large-schema.sql +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docker/localstack-init.sh +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docker/test-redshift.sh +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docs/CONFIGURATION.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docs/ENTERPRISE.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/docs/Redshift.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/README.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/advanced/test_multiple_providers.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/advanced/test_simple_api.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/database_specific/test_odoo_integration.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/default_examples.json +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/documentation/real_world_example.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/getting_started/basic_usage.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/getting_started/simple_demo.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/getting_started/test_api_setup.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/schema_management/test_auto_schema.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/schema_management/test_schema_filters_comprehensive.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/.dockerignore +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/.env.example +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/DOCKER_README.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/DOCKER_SETUP.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/DOCKER_TESTING_SUMMARY.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/Dockerfile +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/INDEX.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/README.md +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/docker/init-ecommerce-schema.sql +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/docker-compose.yml +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/main.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/pyproject.toml +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/test-docker-endpoints.sh +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/install-dev.sh +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/mcp_server/example_config.json +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/mcp_server/provider.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/_provider_errors.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/_provider_validation.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/anthropic_adapter.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/default_repair_policy.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/dict_semantic_resolver.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/file_semantic_resolver.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/gemini_adapter.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/local_embedding_adapter.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/noop_semantic_resolver.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/noop_semantic_validator.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/openai_adapter.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/openai_embedding_adapter.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/pgvector_example_repository.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/schema_repository_execution_adapter.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/config/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/entities.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/provider_config.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/result.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/runtime.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/exceptions/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/factories/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/ai_provider.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/cache.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/embedding_provider.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/error_classifier.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/example_repository.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/query_execution.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/query_optimizer.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/query_safety.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/query_validator.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/repair_policy.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/schema_repository.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/schema_strategy.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/semantic_resolver.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/semantic_validator.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/analyzer.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/embedding_manager.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/example_loader.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/example_store.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/filters.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/manager.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/example_selection_service.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/prompt_assembly_service.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/query_analysis_service.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/query_repair_service.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/semantic_resolution_service.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/semantic_validation_service.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/sql_intent_planning_service.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/artifact_loader.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/helpers.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/logger.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/semantic_prompt.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/storage.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/test_tmp/.gitignore +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/data/gold_questions.json +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/fakes/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/fakes/fake_anthropic.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/fakes/fake_gemini.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/fakes/fake_openai.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/mcp/__init__.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/mcp/test_provider_from_environment.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/mcp/test_sdk_bound.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/mcp/test_sql_security.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_artifact_loader.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_basic.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_batch_scoring.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cli_against_postgres.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cli_base_url.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cli_cache.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cli_inspect.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cli_providers.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cli_query_output.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cli_semantic_support.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_client_hooks.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_client_stats.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_column_validation.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_connect_embeddings.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_connect_ready_provider.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_cost_per_question.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_database_prompts.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_dsl_integration.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_embedding_manager.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_false_invalid_regression.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_first_run.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_integration.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_library_logging.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_library_output.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_llm_validation_contract.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_model_defaults.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_openai_compatible_endpoint.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_pgvector_example_repository.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_postgres_integration.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_provider_compat_llm.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_provider_errors.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_provider_event_loops.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_provider_validation.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_query_result.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_query_service_contract.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_readonly_connections.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_redshift_integration.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_refresh_schema.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_repository_cache.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_retrieval_pipeline.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_schema_context_cache.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_sql_safety.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_sql_safety_against_postgres.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_startup.py +0 -0
- {nlp2sql-0.2.0rc21 → nlp2sql-0.2.0rc22}/tests/test_version_consistency.py +0 -0
|
@@ -112,6 +112,65 @@ jobs:
|
|
|
112
112
|
NLP2SQL_TEST_POSTGRES_DB: testdb
|
|
113
113
|
run: pytest tests/test_first_run.py tests/test_false_invalid_regression.py tests/test_cost_per_question.py tests/test_library_output.py tests/test_cli_against_postgres.py tests/test_sql_safety_against_postgres.py tests/test_readonly_execution_against_postgres.py -m integration -q
|
|
114
114
|
|
|
115
|
+
# MySQL 8.4 LTS and MariaDB 11.4 LTS, each with the e-commerce schema of
|
|
116
|
+
# docker/mysql/init-schema.sql. NLP2SQL_TEST_MYSQL_SERVERS limits the fixtures to the
|
|
117
|
+
# server of this job, and NLP2SQL_REQUIRE_INTEGRATION makes them fail instead of skip.
|
|
118
|
+
mysql-integration:
|
|
119
|
+
runs-on: ubuntu-24.04
|
|
120
|
+
strategy:
|
|
121
|
+
fail-fast: false
|
|
122
|
+
matrix:
|
|
123
|
+
include:
|
|
124
|
+
- server: mysql
|
|
125
|
+
image: mysql:8.4
|
|
126
|
+
health: mysqladmin ping -h 127.0.0.1 -utestuser -ptestpass --silent
|
|
127
|
+
- server: mariadb
|
|
128
|
+
image: mariadb:11.4
|
|
129
|
+
health: healthcheck.sh --connect --innodb_initialized
|
|
130
|
+
|
|
131
|
+
services:
|
|
132
|
+
database:
|
|
133
|
+
image: ${{ matrix.image }}
|
|
134
|
+
env:
|
|
135
|
+
MYSQL_ROOT_PASSWORD: rootpass
|
|
136
|
+
MYSQL_USER: testuser
|
|
137
|
+
MYSQL_PASSWORD: testpass
|
|
138
|
+
MYSQL_DATABASE: testdb
|
|
139
|
+
ports:
|
|
140
|
+
- 3306:3306
|
|
141
|
+
options: >-
|
|
142
|
+
--health-cmd "${{ matrix.health }}"
|
|
143
|
+
--health-interval 10s
|
|
144
|
+
--health-timeout 5s
|
|
145
|
+
--health-retries 10
|
|
146
|
+
|
|
147
|
+
steps:
|
|
148
|
+
- name: Checkout
|
|
149
|
+
uses: actions/checkout@v7
|
|
150
|
+
|
|
151
|
+
- name: Set up Python 3.12
|
|
152
|
+
uses: actions/setup-python@v7
|
|
153
|
+
with:
|
|
154
|
+
python-version: '3.12'
|
|
155
|
+
|
|
156
|
+
- name: Install uv
|
|
157
|
+
run: python -m pip install uv
|
|
158
|
+
|
|
159
|
+
- name: Install dependencies (with the mysql extra)
|
|
160
|
+
run: uv pip install --system ".[dev,mysql]"
|
|
161
|
+
|
|
162
|
+
- name: Load the e-commerce test schema
|
|
163
|
+
run: mysql --protocol=tcp -h 127.0.0.1 -P 3306 -u testuser -ptestpass testdb < docker/mysql/init-schema.sql
|
|
164
|
+
|
|
165
|
+
- name: MySQL integration tests (${{ matrix.server }})
|
|
166
|
+
env:
|
|
167
|
+
PYTHONPATH: src
|
|
168
|
+
NLP2SQL_REQUIRE_INTEGRATION: "1"
|
|
169
|
+
NLP2SQL_TEST_MYSQL_SERVERS: ${{ matrix.server }}
|
|
170
|
+
NLP2SQL_TEST_MYSQL_PORT: "3306"
|
|
171
|
+
NLP2SQL_TEST_MARIADB_PORT: "3306"
|
|
172
|
+
run: pytest tests/test_mysql_test_database.py tests/test_mysql_repository_against_servers.py tests/test_mysql_dialect_against_servers.py -m integration -q
|
|
173
|
+
|
|
115
174
|
# Installs the built wheel the way a user does: fresh environment, no lock
|
|
116
175
|
# file, latest dependency versions. Catches undeclared dependencies (rc13-rc15
|
|
117
176
|
# could not be imported without pyyaml) that the locked dev environment hides.
|
|
@@ -22,6 +22,60 @@ pre-1.0.
|
|
|
22
22
|
|
|
23
23
|
## [Unreleased]
|
|
24
24
|
|
|
25
|
+
## [0.2.0rc22] - 2026-11-20
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **MySQL and MariaDB.** `connect("mysql://user:password@host:3306/database")` works, and so do `mysql+pymysql://` and `mariadb://` URLs. The CLI and the MCP server accept them too. Install the driver with `pip install 'nlp2sql[mysql]'`. Tested against MySQL 8.4 and MariaDB 11.4.
|
|
30
|
+
- A schema is a database: nlp2sql reads the database of the URL. A `schema` other than the default names another database of the same server.
|
|
31
|
+
- Tables, columns, keys, indexes and comments come from `information_schema`, in four queries whatever the number of tables. `row_count` is the storage engine's estimate. Views are not listed, as with PostgreSQL.
|
|
32
|
+
- Every connection is read-only for its whole session (`SET SESSION TRANSACTION READ ONLY`), and it runs one statement per query: the driver does not ask the server for multiple statements.
|
|
33
|
+
- The statement timeout is `max_execution_time` on MySQL and `max_statement_time` on MariaDB. MySQL's does not interrupt every statement, so the client also stops waiting 5 seconds after it.
|
|
34
|
+
- Only these URL parameters are accepted: `charset`, `connect_timeout`, `read_timeout`, `write_timeout`, `unix_socket`, `ssl_ca`, `ssl_cert`, `ssl_key`, `ssl_key_password`, `ssl_disabled`, `ssl_verify_cert` and `ssl_verify_identity`. Any other raises `ConfigurationException`: `local_infile`, `init_command` and `read_default_file` would let a URL read local files or run SQL on connect.
|
|
35
|
+
- The prompt gives the model the rules that differ from PostgreSQL. Two PostgreSQL habits return a wrong answer on these servers instead of an error: `"name"` is a string, and `||` is logical OR.
|
|
36
|
+
- `validate()` and `ask()` warn about PostgreSQL idioms that both servers refuse (`::`, `ILIKE`, `DATE_TRUNC`, `STRING_AGG`, `FULL OUTER JOIN`, `DISTINCT ON`, `NULLS LAST`, `FILTER (WHERE ...)`, `INTERVAL '1 month'`) and about `||`.
|
|
37
|
+
- With `repair=True`, errors are classified by the server's error number, not by the words of the message.
|
|
38
|
+
- The column check reads names in backticks.
|
|
39
|
+
- `nlp2sql setup` offers `mysql` and `mariadb`. `nlp2sql inspect` and the MCP tool `explore_schema` show the database as the schema.
|
|
40
|
+
- See [MySQL and MariaDB Support](https://github.com/luiscarbonel1991/nlp2sql/blob/main/docs/MySQL.md).
|
|
41
|
+
- `is_safe_query()` and `apply_row_limit()` take `dialect=`, a `DatabaseType` or its name. With MySQL (or `"mariadb"`) the read-only check reads the query the way those servers do, which the PostgreSQL reading gets wrong:
|
|
42
|
+
- `$a$ ... $a$` is not a string: MariaDB reads `$a$` as a name, so what is between is code;
|
|
43
|
+
- `--` starts a comment only before whitespace (`5--1` is `5 - (-1)`), and `#` starts one;
|
|
44
|
+
- `` `name` `` is a quoted name, and `"..."` can be a string with backslash escapes;
|
|
45
|
+
- comments that the server runs are rejected: `/*! ... */`, `/*M! ... */` and optimizer hints `/*+ ... */`, which can change session settings such as the statement timeout;
|
|
46
|
+
- `INTO OUTFILE`, `INTO DUMPFILE` and `NEXT VALUE FOR` are rejected, and so are calls to `sleep`, `benchmark`, `load_file`, the `get_lock` family and the replication wait functions;
|
|
47
|
+
- `CHARACTER SET` in a `CAST` is allowed.
|
|
48
|
+
- `validate_sql()` and the validation inside `ask()` pass the database type to the check. Nothing changes for PostgreSQL and Redshift.
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
- **With `repair=True`, a write that the database refused was sent back to the model as a missing table.** The message "cannot execute CREATE TABLE in a read-only transaction" names a table. It is now the `read_only` error category, which is not retried.
|
|
53
|
+
- **`connect()` chose PostgreSQL for every URL that did not mention Redshift.** `connect("mysql://...")` tried to connect with the PostgreSQL driver. `connect()` now reads the database type from the URL scheme, the same way as the CLI and the MCP server, and a URL of a database without an adapter raises `NotImplementedError`.
|
|
54
|
+
- `create_query_service()`, `create_and_initialize_service()` and `generate_sql_from_db()` detect the database type from the URL when `database_type` is not given. It defaulted to PostgreSQL, so a `redshift://` URL got the PostgreSQL repository.
|
|
55
|
+
- A `postgresql://` or `postgres://` URL whose host names Redshift is Redshift in the CLI and the MCP server too, as it already was in `connect()`. Only the host counts: "redshift" in the user, the password or the database name no longer changes the type.
|
|
56
|
+
- The Redshift adapter reads `postgres://` URLs. It took the user and the password from the wrong places.
|
|
57
|
+
- The CLI accepts a URL scheme in any case (`POSTGRESQL://`), as the library does.
|
|
58
|
+
- The MCP server no longer repeats a connection URL it rejects in its error message.
|
|
59
|
+
|
|
60
|
+
### Changed
|
|
61
|
+
|
|
62
|
+
- `mysql+pymysql://` and `mariadb://` URLs are recognized as MySQL.
|
|
63
|
+
- The CLI and the MCP server accept the URL schemes of every database type that has a repository, including one registered with `RepositoryFactory.register()`. The CLI no longer accepts `sqlite://` URLs, which failed later with "not supported".
|
|
64
|
+
- The `mysql` extra installs `pymysql[rsa]`: PyMySQL and `cryptography`, which MySQL 8 sign-in needs on a connection without TLS. It also installed `mysql-connector-python`, which nothing uses.
|
|
65
|
+
|
|
66
|
+
### Removed
|
|
67
|
+
|
|
68
|
+
- The `oracle` and `mssql` extras. They installed drivers for databases that have no adapter.
|
|
69
|
+
|
|
70
|
+
### Security
|
|
71
|
+
|
|
72
|
+
- **The MCP server no longer returns a connection URL with its password.** A tool result goes to the model and stays in the client's history.
|
|
73
|
+
- `explore_schema()` repeated its `database` argument in the answer and in the context of an error. A URL is now shown with `***` as the password.
|
|
74
|
+
- Text that is not a URL came back whole in "Invalid database: '...'", from every tool. A URL typed without `scheme://` is such a text.
|
|
75
|
+
- An error that quotes the URL is masked too, also when the caller passed an alias and never saw the URL.
|
|
76
|
+
- **A connection URL that cannot be read is refused without repeating any of it.** With a `/`, `?` or `#` in the password that was not URL-encoded, `PostgreSQLRepository` raised urllib's "Port could not be cast to integer value as '...'", and the quoted text was the start of the password. Through the MCP server it reached a caller that knew only the alias. PostgreSQL and MySQL URLs now raise `ConfigurationException` (PostgreSQL raised `ValueError`), and the message says to URL-encode those characters.
|
|
77
|
+
- **`mask_database_url()` hides passwords it showed.** A password with an unencoded `/`, `?` or `#` was printed whole, and so were the `sslpassword` and `ssl_key_password` parameters. The CLI prints connection URLs through this function.
|
|
78
|
+
|
|
25
79
|
## [0.2.0rc21] - 2026-11-17
|
|
26
80
|
|
|
27
81
|
### Added
|
|
@@ -169,7 +169,7 @@ class ExampleAdapter(AIProviderPort):
|
|
|
169
169
|
Priority areas for enterprise contributions:
|
|
170
170
|
|
|
171
171
|
- **New AI providers** (AWS Bedrock, Azure OpenAI, etc.)
|
|
172
|
-
- **Database support** (
|
|
172
|
+
- **Database support** (SQLite, Oracle, MSSQL)
|
|
173
173
|
- **Performance optimizations** (caching, schema handling)
|
|
174
174
|
- **Security features** (audit logging, sanitization)
|
|
175
175
|
- **Monitoring** (metrics, health checks, alerting)
|
|
@@ -276,7 +276,6 @@ The PyPI workflow stops before building if the run is not on a tag, if the tag h
|
|
|
276
276
|
### Current Focus Areas
|
|
277
277
|
|
|
278
278
|
1. **Database Support Expansion**
|
|
279
|
-
- MySQL adapter implementation
|
|
280
279
|
- SQLite support for local development
|
|
281
280
|
- Oracle enterprise database support
|
|
282
281
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: nlp2sql
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.0rc22
|
|
4
4
|
Summary: Enterprise-ready Natural Language to SQL converter with multi-provider support. Built for production scale (1000+ tables) with Clean Architecture.
|
|
5
5
|
Project-URL: Homepage, https://github.com/luiscarbonel1991/nlp2sql
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/luiscarbonel1991/nlp2sql/issues
|
|
@@ -67,13 +67,8 @@ Requires-Dist: sentence-transformers>=2.5.0; extra == 'embeddings-local'
|
|
|
67
67
|
Provides-Extra: embeddings-openai
|
|
68
68
|
Provides-Extra: gemini
|
|
69
69
|
Requires-Dist: google-genai>=1.51.0; extra == 'gemini'
|
|
70
|
-
Provides-Extra: mssql
|
|
71
|
-
Requires-Dist: pymssql>=2.2.0; extra == 'mssql'
|
|
72
70
|
Provides-Extra: mysql
|
|
73
|
-
Requires-Dist:
|
|
74
|
-
Requires-Dist: pymysql>=1.1.0; extra == 'mysql'
|
|
75
|
-
Provides-Extra: oracle
|
|
76
|
-
Requires-Dist: oracledb>=2.0.0; extra == 'oracle'
|
|
71
|
+
Requires-Dist: pymysql[rsa]>=1.1.0; extra == 'mysql'
|
|
77
72
|
Provides-Extra: pgvector
|
|
78
73
|
Requires-Dist: pgvector>=0.2.5; extra == 'pgvector'
|
|
79
74
|
Description-Content-Type: text/markdown
|
|
@@ -115,7 +110,7 @@ The library is designed for both simple schemas and large warehouses, but all pu
|
|
|
115
110
|
- **Few-shot examples**: pass example lists directly or use an example repository implementation
|
|
116
111
|
- **Large schema support**: FAISS plus TF-IDF hybrid retrieval, schema filters, and disk-backed caches
|
|
117
112
|
- **Multiple providers**: OpenAI, Anthropic, and Gemini built in; OpenAI-compatible servers such as Ollama and vLLM through `base_url`; or your own `AIProviderPort` passed to `connect()`
|
|
118
|
-
- **Database support**: PostgreSQL
|
|
113
|
+
- **Database support**: PostgreSQL, Amazon Redshift, MySQL and MariaDB built in; register a `SchemaRepositoryPort` implementation with `RepositoryFactory.register()` and pass `database_type=` to `connect()` to add another database
|
|
119
114
|
- **Async by default**: built for services, APIs, notebooks, and workers
|
|
120
115
|
|
|
121
116
|
## Documentation
|
|
@@ -127,6 +122,7 @@ The library is designed for both simple schemas and large warehouses, but all pu
|
|
|
127
122
|
| [Configuration](docs/CONFIGURATION.md) | Environment variables, examples, semantic context, cache behavior |
|
|
128
123
|
| [Enterprise Guide](docs/ENTERPRISE.md) | Governed usage, scale, and deployment patterns |
|
|
129
124
|
| [Redshift Support](docs/Redshift.md) | Redshift-specific notes using public examples |
|
|
125
|
+
| [MySQL and MariaDB Support](docs/MySQL.md) | Install, connection URLs, read-only execution and dialect notes |
|
|
130
126
|
| [Examples](examples/README.md) | Safe public examples based on the local e-commerce domain |
|
|
131
127
|
| [Contributing](CONTRIBUTING.md) | Contribution guidelines |
|
|
132
128
|
|
|
@@ -139,6 +135,9 @@ uv add nlp2sql
|
|
|
139
135
|
# With pip
|
|
140
136
|
pip install nlp2sql
|
|
141
137
|
|
|
138
|
+
# With MySQL or MariaDB
|
|
139
|
+
pip install 'nlp2sql[mysql]'
|
|
140
|
+
|
|
142
141
|
# With specific providers
|
|
143
142
|
pip install nlp2sql[anthropic,gemini]
|
|
144
143
|
pip install nlp2sql[all-providers]
|
|
@@ -35,7 +35,7 @@ The library is designed for both simple schemas and large warehouses, but all pu
|
|
|
35
35
|
- **Few-shot examples**: pass example lists directly or use an example repository implementation
|
|
36
36
|
- **Large schema support**: FAISS plus TF-IDF hybrid retrieval, schema filters, and disk-backed caches
|
|
37
37
|
- **Multiple providers**: OpenAI, Anthropic, and Gemini built in; OpenAI-compatible servers such as Ollama and vLLM through `base_url`; or your own `AIProviderPort` passed to `connect()`
|
|
38
|
-
- **Database support**: PostgreSQL
|
|
38
|
+
- **Database support**: PostgreSQL, Amazon Redshift, MySQL and MariaDB built in; register a `SchemaRepositoryPort` implementation with `RepositoryFactory.register()` and pass `database_type=` to `connect()` to add another database
|
|
39
39
|
- **Async by default**: built for services, APIs, notebooks, and workers
|
|
40
40
|
|
|
41
41
|
## Documentation
|
|
@@ -47,6 +47,7 @@ The library is designed for both simple schemas and large warehouses, but all pu
|
|
|
47
47
|
| [Configuration](docs/CONFIGURATION.md) | Environment variables, examples, semantic context, cache behavior |
|
|
48
48
|
| [Enterprise Guide](docs/ENTERPRISE.md) | Governed usage, scale, and deployment patterns |
|
|
49
49
|
| [Redshift Support](docs/Redshift.md) | Redshift-specific notes using public examples |
|
|
50
|
+
| [MySQL and MariaDB Support](docs/MySQL.md) | Install, connection URLs, read-only execution and dialect notes |
|
|
50
51
|
| [Examples](examples/README.md) | Safe public examples based on the local e-commerce domain |
|
|
51
52
|
| [Contributing](CONTRIBUTING.md) | Contribution guidelines |
|
|
52
53
|
|
|
@@ -59,6 +60,9 @@ uv add nlp2sql
|
|
|
59
60
|
# With pip
|
|
60
61
|
pip install nlp2sql
|
|
61
62
|
|
|
63
|
+
# With MySQL or MariaDB
|
|
64
|
+
pip install 'nlp2sql[mysql]'
|
|
65
|
+
|
|
62
66
|
# With specific providers
|
|
63
67
|
pip install nlp2sql[anthropic,gemini]
|
|
64
68
|
pip install nlp2sql[all-providers]
|
|
@@ -70,6 +70,15 @@ When using nlp2sql in production:
|
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
Do not use a superuser: it can read server files (`pg_read_file`) and end other sessions.
|
|
73
|
+
|
|
74
|
+
In MySQL and MariaDB:
|
|
75
|
+
|
|
76
|
+
```sql
|
|
77
|
+
CREATE USER 'nlp2sql_reader'@'%' IDENTIFIED BY '...';
|
|
78
|
+
GRANT SELECT ON mydb.* TO 'nlp2sql_reader'@'%';
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Do not grant `FILE`: it lets a query read and write files on the database server.
|
|
73
82
|
3. **Enable query validation** to prevent dangerous SQL execution
|
|
74
83
|
4. **Review generated SQL** before executing on sensitive data
|
|
75
84
|
5. **Keep dependencies updated** - Run `uv sync` regularly
|
|
@@ -18,6 +18,17 @@ LARGE_DB_PASSWORD=demo123
|
|
|
18
18
|
LARGE_DB_NAME=enterprise
|
|
19
19
|
LARGE_DB_PORT=5433
|
|
20
20
|
|
|
21
|
+
# MySQL and MariaDB Configuration (same e-commerce schema, mysql/init-schema.sql)
|
|
22
|
+
MYSQL_VERSION=8.4
|
|
23
|
+
MYSQL_CONTAINER_NAME=nlp2sql-mysql
|
|
24
|
+
MYSQL_DB_USER=testuser
|
|
25
|
+
MYSQL_DB_PASSWORD=testpass
|
|
26
|
+
MYSQL_DB_NAME=testdb
|
|
27
|
+
MYSQL_DB_PORT=3306
|
|
28
|
+
MARIADB_VERSION=11.4
|
|
29
|
+
MARIADB_CONTAINER_NAME=nlp2sql-mariadb
|
|
30
|
+
MARIADB_DB_PORT=3307
|
|
31
|
+
|
|
21
32
|
# LocalStack Redshift Configuration
|
|
22
33
|
LOCALSTACK_CONTAINER_NAME=nlp2sql-localstack
|
|
23
34
|
REDSHIFT_PORT=5439
|
|
@@ -23,6 +23,13 @@ This directory contains Docker configurations for testing nlp2sql with PostgreSQ
|
|
|
23
23
|
- **Tables**: Test tables optimized for data warehouse patterns
|
|
24
24
|
- **Use case**: Testing Redshift-specific functionality and compatibility
|
|
25
25
|
|
|
26
|
+
### 4. MySQL 8.4 (Port 3306) and MariaDB 11.4 (Port 3307)
|
|
27
|
+
- **Connection**: `mysql://testuser:testpass@127.0.0.1:3306/testdb` and `mariadb://testuser:testpass@127.0.0.1:3307/testdb`
|
|
28
|
+
- **Schema**: The simple e-commerce schema, translated in `mysql/init-schema.sql`. Keep it in step with `init-schema.sql`
|
|
29
|
+
- **Start**: `docker-compose up -d mysql mariadb`
|
|
30
|
+
- **Data**: No volume. The schema is loaded again when the container is created; `docker-compose rm -sf mysql mariadb` resets it
|
|
31
|
+
- **Use case**: Integration tests of the MySQL adapter (`pytest -m integration tests/test_mysql_test_database.py tests/test_mysql_repository_against_servers.py`). They need the driver: `pip install 'nlp2sql[mysql]'`
|
|
32
|
+
|
|
26
33
|
## Quick Start
|
|
27
34
|
|
|
28
35
|
### Default Setup (No Configuration Needed)
|
|
@@ -37,6 +37,46 @@ services:
|
|
|
37
37
|
timeout: 5s
|
|
38
38
|
retries: 5
|
|
39
39
|
|
|
40
|
+
# MySQL and MariaDB: the same e-commerce schema as postgres, in mysql/init-schema.sql.
|
|
41
|
+
# No data volume: the schema is loaded again each time the container is created.
|
|
42
|
+
mysql:
|
|
43
|
+
image: mysql:${MYSQL_VERSION:-8.4}
|
|
44
|
+
container_name: ${MYSQL_CONTAINER_NAME:-nlp2sql-mysql}
|
|
45
|
+
environment:
|
|
46
|
+
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-rootpass}
|
|
47
|
+
MYSQL_USER: ${MYSQL_DB_USER:-testuser}
|
|
48
|
+
MYSQL_PASSWORD: ${MYSQL_DB_PASSWORD:-testpass}
|
|
49
|
+
MYSQL_DATABASE: ${MYSQL_DB_NAME:-testdb}
|
|
50
|
+
ports:
|
|
51
|
+
- "${MYSQL_DB_PORT:-3306}:3306"
|
|
52
|
+
volumes:
|
|
53
|
+
- ./mysql/init-schema.sql:/docker-entrypoint-initdb.d/init-schema.sql:ro
|
|
54
|
+
restart: unless-stopped
|
|
55
|
+
healthcheck:
|
|
56
|
+
test: ["CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -u${MYSQL_DB_USER:-testuser} -p${MYSQL_DB_PASSWORD:-testpass} --silent"]
|
|
57
|
+
interval: 10s
|
|
58
|
+
timeout: 5s
|
|
59
|
+
retries: 10
|
|
60
|
+
|
|
61
|
+
mariadb:
|
|
62
|
+
image: mariadb:${MARIADB_VERSION:-11.4}
|
|
63
|
+
container_name: ${MARIADB_CONTAINER_NAME:-nlp2sql-mariadb}
|
|
64
|
+
environment:
|
|
65
|
+
MARIADB_ROOT_PASSWORD: ${MARIADB_ROOT_PASSWORD:-rootpass}
|
|
66
|
+
MARIADB_USER: ${MARIADB_DB_USER:-testuser}
|
|
67
|
+
MARIADB_PASSWORD: ${MARIADB_DB_PASSWORD:-testpass}
|
|
68
|
+
MARIADB_DATABASE: ${MARIADB_DB_NAME:-testdb}
|
|
69
|
+
ports:
|
|
70
|
+
- "${MARIADB_DB_PORT:-3307}:3306"
|
|
71
|
+
volumes:
|
|
72
|
+
- ./mysql/init-schema.sql:/docker-entrypoint-initdb.d/init-schema.sql:ro
|
|
73
|
+
restart: unless-stopped
|
|
74
|
+
healthcheck:
|
|
75
|
+
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
|
|
76
|
+
interval: 10s
|
|
77
|
+
timeout: 5s
|
|
78
|
+
retries: 10
|
|
79
|
+
|
|
40
80
|
# LocalStack for Redshift testing
|
|
41
81
|
localstack:
|
|
42
82
|
image: localstack/localstack:latest
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
-- nlp2sql Test Database Schema for MySQL and MariaDB
|
|
2
|
+
-- The same e-commerce example as ../init-schema.sql (PostgreSQL), in MySQL's dialect:
|
|
3
|
+
-- AUTO_INCREMENT keys, foreign keys declared at table level (MySQL parses an inline
|
|
4
|
+
-- REFERENCES and ignores it), table comments in CREATE TABLE, CONCAT() for ||.
|
|
5
|
+
-- Keep the two files in step: the integration tests expect the same tables and rows.
|
|
6
|
+
|
|
7
|
+
-- Store dimension
|
|
8
|
+
CREATE TABLE stores (
|
|
9
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
10
|
+
code VARCHAR(50) UNIQUE NOT NULL,
|
|
11
|
+
domain VARCHAR(120) UNIQUE NOT NULL,
|
|
12
|
+
name VARCHAR(150) NOT NULL,
|
|
13
|
+
region VARCHAR(100) NOT NULL,
|
|
14
|
+
country VARCHAR(100) NOT NULL,
|
|
15
|
+
currency VARCHAR(10) NOT NULL,
|
|
16
|
+
is_active BOOLEAN DEFAULT true,
|
|
17
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
18
|
+
) ENGINE = InnoDB COMMENT = 'Storefront dimension with business region and country metadata';
|
|
19
|
+
|
|
20
|
+
-- Marketing channel dimension
|
|
21
|
+
CREATE TABLE marketing_channels (
|
|
22
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
23
|
+
channel_name VARCHAR(100) NOT NULL,
|
|
24
|
+
source_category VARCHAR(100) NOT NULL,
|
|
25
|
+
traffic_type VARCHAR(50) NOT NULL,
|
|
26
|
+
is_paid BOOLEAN DEFAULT false,
|
|
27
|
+
is_active BOOLEAN DEFAULT true
|
|
28
|
+
) ENGINE = InnoDB COMMENT = 'Marketing channel dimension with business source categories and paid vs non-paid classification';
|
|
29
|
+
|
|
30
|
+
-- Users table
|
|
31
|
+
CREATE TABLE users (
|
|
32
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
33
|
+
email VARCHAR(255) UNIQUE NOT NULL,
|
|
34
|
+
first_name VARCHAR(100) NOT NULL,
|
|
35
|
+
last_name VARCHAR(100) NOT NULL,
|
|
36
|
+
phone VARCHAR(20),
|
|
37
|
+
date_created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
38
|
+
last_login TIMESTAMP NULL,
|
|
39
|
+
is_active BOOLEAN DEFAULT true,
|
|
40
|
+
city VARCHAR(100),
|
|
41
|
+
country VARCHAR(100),
|
|
42
|
+
region VARCHAR(100),
|
|
43
|
+
customer_segment VARCHAR(50) DEFAULT 'standard',
|
|
44
|
+
preferred_store_id INT,
|
|
45
|
+
FOREIGN KEY (preferred_store_id) REFERENCES stores(id)
|
|
46
|
+
) ENGINE = InnoDB COMMENT = 'Customer information, region, segment, and preferred storefront';
|
|
47
|
+
|
|
48
|
+
-- Categories table
|
|
49
|
+
CREATE TABLE categories (
|
|
50
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
51
|
+
name VARCHAR(100) NOT NULL,
|
|
52
|
+
description TEXT,
|
|
53
|
+
parent_id INT,
|
|
54
|
+
is_active BOOLEAN DEFAULT true,
|
|
55
|
+
FOREIGN KEY (parent_id) REFERENCES categories(id)
|
|
56
|
+
) ENGINE = InnoDB COMMENT = 'Product categorization hierarchy';
|
|
57
|
+
|
|
58
|
+
-- Products table
|
|
59
|
+
CREATE TABLE products (
|
|
60
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
61
|
+
name VARCHAR(200) NOT NULL,
|
|
62
|
+
description TEXT,
|
|
63
|
+
brand VARCHAR(100) NOT NULL,
|
|
64
|
+
product_line VARCHAR(100),
|
|
65
|
+
price DECIMAL(10,2) NOT NULL,
|
|
66
|
+
category_id INT,
|
|
67
|
+
stock_quantity INT DEFAULT 0,
|
|
68
|
+
sku VARCHAR(50) UNIQUE,
|
|
69
|
+
is_active BOOLEAN DEFAULT true,
|
|
70
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
71
|
+
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
72
|
+
FOREIGN KEY (category_id) REFERENCES categories(id)
|
|
73
|
+
) ENGINE = InnoDB COMMENT = 'Product catalog with brand, category, inventory and pricing';
|
|
74
|
+
|
|
75
|
+
-- Orders table
|
|
76
|
+
CREATE TABLE orders (
|
|
77
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
78
|
+
user_id INT,
|
|
79
|
+
store_id INT,
|
|
80
|
+
channel_id INT,
|
|
81
|
+
total_amount DECIMAL(10,2) NOT NULL,
|
|
82
|
+
discount_amount DECIMAL(10,2) DEFAULT 0,
|
|
83
|
+
status VARCHAR(20) DEFAULT 'pending',
|
|
84
|
+
order_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
85
|
+
shipping_address TEXT,
|
|
86
|
+
payment_method VARCHAR(50),
|
|
87
|
+
promo_code VARCHAR(50),
|
|
88
|
+
notes TEXT,
|
|
89
|
+
FOREIGN KEY (user_id) REFERENCES users(id),
|
|
90
|
+
FOREIGN KEY (store_id) REFERENCES stores(id),
|
|
91
|
+
FOREIGN KEY (channel_id) REFERENCES marketing_channels(id)
|
|
92
|
+
) ENGINE = InnoDB COMMENT = 'Transactional orders tied to stores and marketing channels';
|
|
93
|
+
|
|
94
|
+
-- Order items table
|
|
95
|
+
CREATE TABLE order_items (
|
|
96
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
97
|
+
order_id INT,
|
|
98
|
+
product_id INT,
|
|
99
|
+
quantity INT NOT NULL,
|
|
100
|
+
unit_price DECIMAL(10,2) NOT NULL,
|
|
101
|
+
total_price DECIMAL(10,2) NOT NULL,
|
|
102
|
+
FOREIGN KEY (order_id) REFERENCES orders(id),
|
|
103
|
+
FOREIGN KEY (product_id) REFERENCES products(id)
|
|
104
|
+
) ENGINE = InnoDB COMMENT = 'Individual items within each order';
|
|
105
|
+
|
|
106
|
+
-- Reviews table
|
|
107
|
+
CREATE TABLE reviews (
|
|
108
|
+
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
109
|
+
product_id INT,
|
|
110
|
+
user_id INT,
|
|
111
|
+
rating INT CHECK (rating >= 1 AND rating <= 5),
|
|
112
|
+
title VARCHAR(200),
|
|
113
|
+
comment TEXT,
|
|
114
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
115
|
+
is_verified BOOLEAN DEFAULT false,
|
|
116
|
+
FOREIGN KEY (product_id) REFERENCES products(id),
|
|
117
|
+
FOREIGN KEY (user_id) REFERENCES users(id)
|
|
118
|
+
) ENGINE = InnoDB COMMENT = 'Product reviews and ratings from customers';
|
|
119
|
+
|
|
120
|
+
-- Daily aggregate table used to test business-aware table selection
|
|
121
|
+
CREATE TABLE daily_channel_metrics (
|
|
122
|
+
metric_date DATE NOT NULL,
|
|
123
|
+
store_id INT,
|
|
124
|
+
channel_id INT,
|
|
125
|
+
sessions INT NOT NULL,
|
|
126
|
+
add_to_cart_sessions INT NOT NULL,
|
|
127
|
+
checkout_sessions INT NOT NULL,
|
|
128
|
+
orders_count INT NOT NULL,
|
|
129
|
+
revenue DECIMAL(10,2) NOT NULL,
|
|
130
|
+
PRIMARY KEY (metric_date, store_id, channel_id),
|
|
131
|
+
FOREIGN KEY (store_id) REFERENCES stores(id),
|
|
132
|
+
FOREIGN KEY (channel_id) REFERENCES marketing_channels(id)
|
|
133
|
+
) ENGINE = InnoDB COMMENT = 'Daily aggregated ecommerce funnel and revenue metrics by store and marketing channel';
|
|
134
|
+
|
|
135
|
+
-- Seed stores
|
|
136
|
+
INSERT INTO stores (code, domain, name, region, country, currency, is_active) VALUES
|
|
137
|
+
('na_flagship', 'demo-flagship.com', 'Demo Flagship', 'North America', 'United States', 'USD', true),
|
|
138
|
+
('eu_boutique', 'demo-boutique.eu', 'Demo Boutique Europe', 'Europe', 'Germany', 'EUR', true),
|
|
139
|
+
('ca_outlet', 'demo-outlet.ca', 'Demo Outlet Canada', 'North America', 'Canada', 'CAD', true);
|
|
140
|
+
|
|
141
|
+
-- Seed channels
|
|
142
|
+
INSERT INTO marketing_channels (channel_name, source_category, traffic_type, is_paid, is_active) VALUES
|
|
143
|
+
('Email', 'Email', 'owned', false, true),
|
|
144
|
+
('Organic Search', 'Organic Search', 'organic', false, true),
|
|
145
|
+
('Paid Search', 'Paid Search', 'paid', true, true),
|
|
146
|
+
('Paid Social', 'Paid Social', 'paid', true, true),
|
|
147
|
+
('Affiliate', 'Affiliate', 'partner', false, true);
|
|
148
|
+
|
|
149
|
+
-- Seed users
|
|
150
|
+
INSERT INTO users (
|
|
151
|
+
email, first_name, last_name, phone, city, country, region,
|
|
152
|
+
is_active, customer_segment, preferred_store_id
|
|
153
|
+
) VALUES
|
|
154
|
+
('john.doe@email.com', 'John', 'Doe', '+1234567890', 'New York', 'United States', 'North America', true, 'vip', 1),
|
|
155
|
+
('jane.smith@email.com', 'Jane', 'Smith', '+1234567891', 'Berlin', 'Germany', 'Europe', true, 'standard', 2),
|
|
156
|
+
('carlos.garcia@email.com', 'Carlos', 'Garcia', '+1234567892', 'Toronto', 'Canada', 'North America', true, 'growth', 3),
|
|
157
|
+
('anna.muller@email.com', 'Anna', 'Muller', '+1234567893', 'Munich', 'Germany', 'Europe', true, 'vip', 2),
|
|
158
|
+
('mike.johnson@email.com', 'Mike', 'Johnson', '+1234567894', 'Chicago', 'United States', 'North America', false, 'standard', 1),
|
|
159
|
+
('lisa.wong@email.com', 'Lisa', 'Wong', '+1234567895', 'Vancouver', 'Canada', 'North America', true, 'growth', 3),
|
|
160
|
+
('omar.hassan@email.com', 'Omar', 'Hassan', '+1234567896', 'Austin', 'United States', 'North America', true, 'vip', 1),
|
|
161
|
+
('sofia.rossi@email.com', 'Sofia', 'Rossi', '+1234567897', 'Hamburg', 'Germany', 'Europe', true, 'standard', 2);
|
|
162
|
+
|
|
163
|
+
-- Seed categories
|
|
164
|
+
INSERT INTO categories (name, description, is_active) VALUES
|
|
165
|
+
('Electronics', 'Electronic devices and gadgets', true),
|
|
166
|
+
('Books', 'Physical and digital books', true),
|
|
167
|
+
('Clothing', 'Fashion and apparel', true),
|
|
168
|
+
('Home & Garden', 'Home improvement and garden supplies', true),
|
|
169
|
+
('Sports', 'Sports equipment and accessories', true);
|
|
170
|
+
|
|
171
|
+
-- Seed products
|
|
172
|
+
INSERT INTO products (
|
|
173
|
+
name, description, brand, product_line, price, category_id,
|
|
174
|
+
stock_quantity, sku, is_active
|
|
175
|
+
) VALUES
|
|
176
|
+
('Laptop Pro 15"', 'High-performance laptop for professionals', 'Northwind', 'Pro Computing', 1299.99, 1, 25, 'LAPTOP-PRO-15', true),
|
|
177
|
+
('Wireless Headphones', 'Noise-cancelling wireless headphones', 'Northwind', 'Audio Plus', 299.99, 1, 50, 'WH-NC-001', true),
|
|
178
|
+
('Programming Guide', 'Complete guide to modern programming', 'PageTurner', 'Developer Library', 49.99, 2, 100, 'BOOK-PROG-001', true),
|
|
179
|
+
('Cotton T-Shirt', 'Comfortable cotton t-shirt', 'Evergreen', 'Core Basics', 19.99, 3, 200, 'TSHIRT-COT-001', true),
|
|
180
|
+
('Running Shoes', 'Professional running shoes', 'Evergreen', 'Motion', 129.99, 5, 75, 'SHOES-RUN-001', true),
|
|
181
|
+
('Garden Tool Set', 'Complete garden tool set', 'HomeCraft', 'Outdoor Living', 89.99, 4, 30, 'GARDEN-TOOLS-001', true),
|
|
182
|
+
('Smartphone', 'Latest smartphone with advanced features', 'Northwind', 'Mobile X', 899.99, 1, 40, 'PHONE-ADV-001', true),
|
|
183
|
+
('Cooking Book', 'International cooking recipes', 'PageTurner', 'Kitchen Stories', 29.99, 2, 60, 'BOOK-COOK-001', true),
|
|
184
|
+
('Fitness Tracker', 'Wearable tracker for active customers', 'Northwind', 'Motion', 199.99, 5, 90, 'TRACKER-FIT-001', true),
|
|
185
|
+
('Premium Hoodie', 'Heavyweight premium hoodie', 'Evergreen', 'Core Basics', 59.99, 3, 120, 'HOODIE-PREM-001', true);
|
|
186
|
+
|
|
187
|
+
-- Seed orders
|
|
188
|
+
INSERT INTO orders (
|
|
189
|
+
user_id, store_id, channel_id, total_amount, discount_amount,
|
|
190
|
+
status, order_date, shipping_address, payment_method, promo_code
|
|
191
|
+
) VALUES
|
|
192
|
+
(1, 1, 3, 1349.98, 0.00, 'completed', '2024-01-15 10:30:00', '123 Main St, New York, NY', 'credit_card', NULL),
|
|
193
|
+
(2, 2, 1, 319.98, 20.00, 'shipped', '2024-01-16 14:20:00', '456 Oak Ave, Berlin, Germany', 'paypal', 'WELCOME20'),
|
|
194
|
+
(3, 3, 2, 49.99, 0.00, 'completed', '2024-01-17 09:15:00', '789 Pine St, Toronto, Canada', 'credit_card', NULL),
|
|
195
|
+
(1, 1, 4, 149.98, 10.00, 'completed', '2024-01-18 16:45:00', '123 Main St, New York, NY', 'debit_card', 'SOCIAL10'),
|
|
196
|
+
(4, 2, 3, 929.98, 0.00, 'processing', '2024-01-19 11:30:00', '321 Elm St, Munich, Germany', 'credit_card', NULL),
|
|
197
|
+
(6, 3, 5, 219.98, 0.00, 'completed', '2024-01-19 18:20:00', '654 Queen St, Vancouver, Canada', 'credit_card', NULL),
|
|
198
|
+
(7, 1, 2, 199.99, 0.00, 'completed', '2024-01-20 08:05:00', '987 Lake Ave, Austin, TX', 'paypal', NULL),
|
|
199
|
+
(8, 2, 4, 79.98, 5.00, 'pending', '2024-01-20 12:10:00', '741 Birch Rd, Hamburg, Germany', 'credit_card', 'NEW5'),
|
|
200
|
+
(1, 1, 1, 59.99, 0.00, 'completed', '2024-01-21 09:25:00', '123 Main St, New York, NY', 'credit_card', NULL),
|
|
201
|
+
(3, 3, 2, 899.99, 50.00, 'completed', '2024-01-21 16:00:00', '789 Pine St, Toronto, Canada', 'bank_transfer', 'SEARCH50'),
|
|
202
|
+
(2, 2, 3, 259.98, 0.00, 'completed', '2024-01-22 10:45:00', '456 Oak Ave, Berlin, Germany', 'credit_card', NULL),
|
|
203
|
+
(7, 1, 4, 159.98, 0.00, 'completed', '2024-01-22 15:35:00', '987 Lake Ave, Austin, TX', 'paypal', NULL);
|
|
204
|
+
|
|
205
|
+
-- Seed order items
|
|
206
|
+
INSERT INTO order_items (order_id, product_id, quantity, unit_price, total_price) VALUES
|
|
207
|
+
(1, 1, 1, 1299.99, 1299.99),
|
|
208
|
+
(1, 3, 1, 49.99, 49.99),
|
|
209
|
+
(2, 2, 1, 299.99, 299.99),
|
|
210
|
+
(2, 4, 1, 19.99, 19.99),
|
|
211
|
+
(3, 3, 1, 49.99, 49.99),
|
|
212
|
+
(4, 5, 1, 129.99, 129.99),
|
|
213
|
+
(4, 4, 1, 19.99, 19.99),
|
|
214
|
+
(5, 7, 1, 899.99, 899.99),
|
|
215
|
+
(5, 8, 1, 29.99, 29.99),
|
|
216
|
+
(6, 9, 1, 199.99, 199.99),
|
|
217
|
+
(6, 8, 1, 29.99, 29.99),
|
|
218
|
+
(7, 9, 1, 199.99, 199.99),
|
|
219
|
+
(8, 4, 1, 19.99, 19.99),
|
|
220
|
+
(8, 8, 2, 29.99, 59.98),
|
|
221
|
+
(9, 10, 1, 59.99, 59.99),
|
|
222
|
+
(10, 7, 1, 899.99, 899.99),
|
|
223
|
+
(11, 2, 1, 299.99, 299.99),
|
|
224
|
+
(11, 8, 1, 29.99, 29.99),
|
|
225
|
+
(12, 5, 1, 129.99, 129.99),
|
|
226
|
+
(12, 4, 1, 19.99, 19.99);
|
|
227
|
+
|
|
228
|
+
-- Seed reviews
|
|
229
|
+
INSERT INTO reviews (product_id, user_id, rating, title, comment, is_verified) VALUES
|
|
230
|
+
(1, 1, 5, 'Excellent laptop!', 'Great performance and build quality. Highly recommended for professionals.', true),
|
|
231
|
+
(2, 2, 4, 'Good headphones', 'Sound quality is great, but could be more comfortable for long use.', true),
|
|
232
|
+
(3, 3, 5, 'Very helpful book', 'Clear explanations and practical examples. Perfect for beginners.', true),
|
|
233
|
+
(4, 1, 3, 'Average quality', 'The fabric is okay but not as soft as expected.', false),
|
|
234
|
+
(5, 4, 5, 'Perfect running shoes', 'Comfortable and durable. Great for daily running.', true),
|
|
235
|
+
(9, 6, 4, 'Helpful tracker', 'Solid activity tracking and battery life.', true),
|
|
236
|
+
(10, 7, 5, 'Great hoodie', 'Warm, premium feel, and true to size.', true);
|
|
237
|
+
|
|
238
|
+
-- Seed daily aggregate facts
|
|
239
|
+
INSERT INTO daily_channel_metrics (
|
|
240
|
+
metric_date, store_id, channel_id, sessions, add_to_cart_sessions,
|
|
241
|
+
checkout_sessions, orders_count, revenue
|
|
242
|
+
) VALUES
|
|
243
|
+
('2024-01-15', 1, 3, 320, 74, 45, 18, 3150.00),
|
|
244
|
+
('2024-01-15', 1, 4, 280, 61, 36, 14, 2210.00),
|
|
245
|
+
('2024-01-16', 1, 1, 190, 42, 27, 11, 980.00),
|
|
246
|
+
('2024-01-16', 2, 1, 150, 30, 20, 9, 720.00),
|
|
247
|
+
('2024-01-17', 3, 2, 210, 39, 25, 10, 860.00),
|
|
248
|
+
('2024-01-18', 1, 4, 295, 68, 40, 15, 2445.00),
|
|
249
|
+
('2024-01-19', 2, 3, 260, 55, 33, 13, 2010.00),
|
|
250
|
+
('2024-01-19', 3, 5, 130, 22, 15, 7, 560.00),
|
|
251
|
+
('2024-01-20', 1, 2, 240, 48, 30, 12, 1180.00),
|
|
252
|
+
('2024-01-20', 2, 4, 205, 36, 24, 8, 760.00),
|
|
253
|
+
('2024-01-21', 1, 1, 215, 44, 28, 12, 1040.00),
|
|
254
|
+
('2024-01-21', 3, 2, 225, 43, 27, 11, 990.00),
|
|
255
|
+
('2024-01-22', 2, 3, 270, 59, 35, 14, 2140.00),
|
|
256
|
+
('2024-01-22', 1, 4, 305, 72, 44, 16, 2580.00);
|
|
257
|
+
|
|
258
|
+
-- Create indexes for better query performance
|
|
259
|
+
CREATE INDEX idx_users_email ON users(email);
|
|
260
|
+
CREATE INDEX idx_users_active ON users(is_active);
|
|
261
|
+
CREATE INDEX idx_users_store ON users(preferred_store_id);
|
|
262
|
+
CREATE INDEX idx_orders_user_id ON orders(user_id);
|
|
263
|
+
CREATE INDEX idx_orders_store_id ON orders(store_id);
|
|
264
|
+
CREATE INDEX idx_orders_channel_id ON orders(channel_id);
|
|
265
|
+
CREATE INDEX idx_orders_status ON orders(status);
|
|
266
|
+
CREATE INDEX idx_orders_date ON orders(order_date);
|
|
267
|
+
CREATE INDEX idx_products_category ON products(category_id);
|
|
268
|
+
CREATE INDEX idx_products_brand ON products(brand);
|
|
269
|
+
CREATE INDEX idx_products_active ON products(is_active);
|
|
270
|
+
CREATE INDEX idx_order_items_order ON order_items(order_id);
|
|
271
|
+
CREATE INDEX idx_order_items_product ON order_items(product_id);
|
|
272
|
+
CREATE INDEX idx_reviews_product ON reviews(product_id);
|
|
273
|
+
CREATE INDEX idx_reviews_user ON reviews(user_id);
|
|
274
|
+
CREATE INDEX idx_daily_channel_metrics_store_date ON daily_channel_metrics(store_id, metric_date);
|
|
275
|
+
CREATE INDEX idx_daily_channel_metrics_channel_date ON daily_channel_metrics(channel_id, metric_date);
|
|
276
|
+
|
|
277
|
+
-- Create views for richer reporting examples
|
|
278
|
+
CREATE VIEW order_summaries AS
|
|
279
|
+
SELECT
|
|
280
|
+
o.id AS order_id,
|
|
281
|
+
s.code AS store_code,
|
|
282
|
+
s.domain AS store_domain,
|
|
283
|
+
s.region,
|
|
284
|
+
s.country,
|
|
285
|
+
mc.channel_name,
|
|
286
|
+
mc.source_category,
|
|
287
|
+
CONCAT(u.first_name, ' ', u.last_name) AS customer_name,
|
|
288
|
+
u.email AS customer_email,
|
|
289
|
+
o.total_amount,
|
|
290
|
+
o.discount_amount,
|
|
291
|
+
o.status,
|
|
292
|
+
o.order_date,
|
|
293
|
+
COUNT(oi.id) AS item_count
|
|
294
|
+
FROM orders o
|
|
295
|
+
JOIN users u ON o.user_id = u.id
|
|
296
|
+
JOIN stores s ON o.store_id = s.id
|
|
297
|
+
JOIN marketing_channels mc ON o.channel_id = mc.id
|
|
298
|
+
LEFT JOIN order_items oi ON o.id = oi.order_id
|
|
299
|
+
GROUP BY
|
|
300
|
+
o.id, s.code, s.domain, s.region, s.country,
|
|
301
|
+
mc.channel_name, mc.source_category,
|
|
302
|
+
u.first_name, u.last_name, u.email,
|
|
303
|
+
o.total_amount, o.discount_amount, o.status, o.order_date;
|
|
304
|
+
|
|
305
|
+
CREATE VIEW store_channel_sales AS
|
|
306
|
+
SELECT
|
|
307
|
+
DATE(o.order_date) AS metric_date,
|
|
308
|
+
s.code AS store_code,
|
|
309
|
+
s.region,
|
|
310
|
+
s.country,
|
|
311
|
+
mc.source_category,
|
|
312
|
+
COUNT(DISTINCT o.id) AS orders_count,
|
|
313
|
+
ROUND(SUM(o.total_amount), 2) AS revenue
|
|
314
|
+
FROM orders o
|
|
315
|
+
JOIN stores s ON o.store_id = s.id
|
|
316
|
+
JOIN marketing_channels mc ON o.channel_id = mc.id
|
|
317
|
+
GROUP BY DATE(o.order_date), s.code, s.region, s.country, mc.source_category;
|
|
@@ -168,7 +168,7 @@ If you do not pass `execution_mode`, the library infers it from `validate` and `
|
|
|
168
168
|
| `is_valid` | `bool` | Final validation state |
|
|
169
169
|
| `explanation` | `str | None` | Optional natural-language explanation |
|
|
170
170
|
| `provider` | `str` | Provider that generated the SQL |
|
|
171
|
-
| `database_type` | `str` | Postgres or
|
|
171
|
+
| `database_type` | `str` | Postgres, Redshift or MySQL |
|
|
172
172
|
| `tokens_used` | `int` | Tokens of every LLM call made for the question |
|
|
173
173
|
| `generation_time_ms` | `float` | End-to-end generation time |
|
|
174
174
|
| `examples_used` | `int` | Count of selected examples |
|