nlp2sql 0.2.0rc20__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.0rc20 → nlp2sql-0.2.0rc22}/.github/workflows/ci.yml +60 -1
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/CHANGELOG.md +167 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/CONTRIBUTING.md +1 -2
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/PKG-INFO +29 -13
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/README.md +24 -3
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/SECURITY.md +9 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docker/.env.example +11 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docker/README.md +7 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docker/docker-compose.yml +40 -0
- nlp2sql-0.2.0rc22/docker/mysql/init-schema.sql +317 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docs/API.md +32 -4
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docs/ARCHITECTURE.md +3 -2
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docs/CONFIGURATION.md +106 -1
- nlp2sql-0.2.0rc22/docs/MySQL.md +139 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/advanced/test_multiple_providers.py +2 -2
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/mcp_server/README.md +44 -4
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/mcp_server/__init__.py +1 -1
- nlp2sql-0.2.0rc22/mcp_server/provider.py +78 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/mcp_server/pyproject.toml +4 -3
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/mcp_server/server.py +47 -59
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/pyproject.toml +13 -9
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/__init__.py +67 -28
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/_provider_errors.py +5 -3
- nlp2sql-0.2.0rc22/src/nlp2sql/adapters/_provider_validation.py +26 -0
- nlp2sql-0.2.0rc22/src/nlp2sql/adapters/_tables_cache.py +139 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/anthropic_adapter.py +19 -26
- nlp2sql-0.2.0rc22/src/nlp2sql/adapters/default_error_classifier.py +147 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/gemini_adapter.py +144 -107
- nlp2sql-0.2.0rc22/src/nlp2sql/adapters/mysql_repository.py +548 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/openai_adapter.py +103 -27
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/openai_embedding_adapter.py +7 -3
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/postgres_repository.py +15 -137
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/redshift_adapter.py +9 -122
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/regex_query_validator.py +3 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/cli.py +145 -64
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/client.py +32 -17
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/config/settings.py +1 -1
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/database_prompts.py +27 -1
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/provider_config.py +18 -1
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/sql_keywords.py +29 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/sql_safety.py +151 -31
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/factories/repository_factory.py +60 -40
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/__init__.py +10 -1
- nlp2sql-0.2.0rc22/src/nlp2sql/ports/ai_provider.py +144 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/query_service.py +65 -19
- nlp2sql-0.2.0rc22/src/nlp2sql/utils/redaction.py +58 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/conftest.py +77 -1
- nlp2sql-0.2.0rc22/tests/fakes/fake_anthropic.py +104 -0
- nlp2sql-0.2.0rc22/tests/fakes/fake_gemini.py +134 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/fakes/fake_openai.py +19 -5
- nlp2sql-0.2.0rc22/tests/mcp/test_database_url_in_tool_results.py +177 -0
- nlp2sql-0.2.0rc22/tests/mcp/test_provider_from_environment.py +125 -0
- nlp2sql-0.2.0rc22/tests/mcp/test_sdk_bound.py +42 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_cli_against_postgres.py +33 -0
- nlp2sql-0.2.0rc22/tests/test_cli_base_url.py +195 -0
- nlp2sql-0.2.0rc22/tests/test_cli_query_output.py +48 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_cli_setup.py +4 -2
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_connect_embeddings.py +64 -0
- nlp2sql-0.2.0rc22/tests/test_connect_ready_provider.py +67 -0
- nlp2sql-0.2.0rc22/tests/test_database_type_detection.py +110 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_first_run.py +45 -1
- nlp2sql-0.2.0rc22/tests/test_llm_validation_contract.py +117 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_model_defaults.py +123 -19
- 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.0rc22/tests/test_openai_compatible_endpoint.py +222 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_provider_compat_llm.py +124 -34
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_provider_errors.py +93 -46
- nlp2sql-0.2.0rc22/tests/test_provider_event_loops.py +82 -0
- nlp2sql-0.2.0rc22/tests/test_provider_validation.py +119 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_query_service_contract.py +114 -0
- {nlp2sql-0.2.0rc20 → 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.0rc20 → 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.0rc22/uv.lock +6264 -0
- nlp2sql-0.2.0rc20/src/nlp2sql/adapters/default_error_classifier.py +0 -65
- nlp2sql-0.2.0rc20/src/nlp2sql/ports/ai_provider.py +0 -71
- nlp2sql-0.2.0rc20/src/nlp2sql/utils/redaction.py +0 -31
- nlp2sql-0.2.0rc20/tests/test_redaction.py +0 -34
- nlp2sql-0.2.0rc20/uv.lock +0 -4433
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.claude/commands/db.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.claude/commands/quality.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.claude/commands/test.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.claude/rules/adapters.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.claude/rules/architecture.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.claude/rules/python-style.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.claude/rules/testing.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.claude/settings.json +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.github/pull_request_template.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.github/scripts/verify_release_tag.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.github/workflows/publish-pypi.yml +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.github/workflows/publish-testpypi.yml +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.gitignore +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.mcp.json.example +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/.python-version +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/CLAUDE.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/CODE_OF_CONDUCT.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/LICENSE +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/assets/nlp2sql-hero-dark.svg +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/assets/nlp2sql-hero-light.svg +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/benchmarks/enterprise_benchmark_results.json +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docker/get-db-urls.sh +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docker/init-schema.sql +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docker/large-schema.sql +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docker/localstack-init.sh +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docker/test-redshift.sh +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docs/ENTERPRISE.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/docs/Redshift.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/README.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/advanced/test_simple_api.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/database_specific/test_odoo_integration.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/default_examples.json +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/documentation/real_world_example.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/getting_started/basic_usage.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/getting_started/simple_demo.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/getting_started/test_api_setup.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/schema_management/test_auto_schema.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/schema_management/test_schema_filters_comprehensive.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/.dockerignore +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/.env.example +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/DOCKER_README.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/DOCKER_SETUP.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/DOCKER_TESTING_SUMMARY.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/Dockerfile +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/INDEX.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/README.md +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/docker/init-ecommerce-schema.sql +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/docker-compose.yml +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/main.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/pyproject.toml +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/examples/strands-fastapi-agent/test-docker-endpoints.sh +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/install-dev.sh +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/mcp_server/example_config.json +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/default_repair_policy.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/dict_semantic_resolver.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/file_semantic_resolver.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/local_embedding_adapter.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/noop_semantic_resolver.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/noop_semantic_validator.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/pgvector_example_repository.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/adapters/schema_repository_execution_adapter.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/config/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/entities.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/result.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/core/runtime.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/exceptions/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/factories/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/cache.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/embedding_provider.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/error_classifier.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/example_repository.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/query_execution.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/query_optimizer.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/query_safety.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/query_validator.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/repair_policy.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/schema_repository.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/schema_strategy.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/semantic_resolver.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/ports/semantic_validator.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/analyzer.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/embedding_manager.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/example_loader.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/example_store.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/filters.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/schema/manager.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/example_selection_service.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/prompt_assembly_service.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/query_analysis_service.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/query_repair_service.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/semantic_resolution_service.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/semantic_validation_service.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/services/sql_intent_planning_service.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/artifact_loader.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/helpers.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/logger.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/semantic_prompt.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/src/nlp2sql/utils/storage.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/test_tmp/.gitignore +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/data/gold_questions.json +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/fakes/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/mcp/__init__.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/mcp/test_sql_security.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_artifact_loader.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_basic.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_batch_scoring.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_cli_cache.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_cli_inspect.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_cli_providers.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_cli_semantic_support.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_client_hooks.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_client_stats.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_column_validation.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_cost_per_question.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_database_prompts.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_dsl_integration.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_embedding_manager.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_false_invalid_regression.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_integration.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_library_logging.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_library_output.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_pgvector_example_repository.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_postgres_integration.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_query_result.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_readonly_connections.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_redshift_integration.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_refresh_schema.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_repository_cache.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_retrieval_pipeline.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_schema_context_cache.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_sql_safety.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_sql_safety_against_postgres.py +0 -0
- {nlp2sql-0.2.0rc20 → nlp2sql-0.2.0rc22}/tests/test_startup.py +0 -0
- {nlp2sql-0.2.0rc20 → 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.
|
|
@@ -136,7 +195,7 @@ jobs:
|
|
|
136
195
|
run: |
|
|
137
196
|
python -m venv "$RUNNER_TEMP/clean"
|
|
138
197
|
"$RUNNER_TEMP/clean/bin/pip" install dist/*.whl
|
|
139
|
-
"$RUNNER_TEMP/clean/bin/pip" list | grep -iE "^(openai|anthropic|google-
|
|
198
|
+
"$RUNNER_TEMP/clean/bin/pip" list | grep -iE "^(openai|anthropic|google-genai|pyyaml) "
|
|
140
199
|
|
|
141
200
|
- name: Import the package and run the CLI
|
|
142
201
|
working-directory: ${{ runner.temp }}
|
|
@@ -22,6 +22,173 @@ 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
|
+
|
|
79
|
+
## [0.2.0rc21] - 2026-11-17
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
- `OpenAIAdapter` takes `base_url`, or a ready-made `client`, to use another server that
|
|
83
|
+
speaks the Chat Completions API, such as Ollama, vLLM or a gateway.
|
|
84
|
+
- The OpenAI key of the environment is not sent to that server. Only an `api_key` passed
|
|
85
|
+
together with `base_url` is, and a placeholder when there is none.
|
|
86
|
+
- OpenAI model names keep their request parameters. Any other name is treated as an open
|
|
87
|
+
model and is sent `temperature` and `max_tokens`, the parameters every compatible
|
|
88
|
+
server implements. Pass `reasoning_effort` to say that it is a reasoning model.
|
|
89
|
+
- `client` is the SDK's sync client (`openai.OpenAI`). An `AsyncOpenAI` client is rejected.
|
|
90
|
+
- Token counts use an OpenAI tokenizer, so for other models they are an estimate.
|
|
91
|
+
- `ProviderConfig` takes `base_url`, so `connect()` and `create_ai_provider` reach those
|
|
92
|
+
servers too: `ProviderConfig(provider="openai", base_url="http://localhost:11434/v1",
|
|
93
|
+
model="llama3.2")`. It is only accepted for the `openai` provider.
|
|
94
|
+
- `connect(provider=...)` also takes a ready AI provider, such as `OpenAIAdapter(client=...)`
|
|
95
|
+
or your own `AIProviderPort`. So does the `ai_provider` argument of
|
|
96
|
+
`create_and_initialize_service`, `create_query_service` and `generate_sql_from_db`.
|
|
97
|
+
- With `base_url` or a ready provider, `connect()` does not default to OpenAI embeddings,
|
|
98
|
+
and the chat key is never sent to OpenAI. It uses local embeddings when
|
|
99
|
+
`nlp2sql[embeddings-local]` is installed, and none otherwise.
|
|
100
|
+
- `nlp2sql query`, `nlp2sql providers test` and `nlp2sql benchmark` take `--base-url`, to use
|
|
101
|
+
an OpenAI-compatible server from the CLI: `nlp2sql query ... --base-url
|
|
102
|
+
http://localhost:11434/v1 --model llama3.2`.
|
|
103
|
+
- No key is needed. Only `--api-key` is sent to that server, never `OPENAI_API_KEY`.
|
|
104
|
+
- `providers test --base-url` checks that server with one request, and takes `--model` and
|
|
105
|
+
`--api-key`.
|
|
106
|
+
- `benchmark --base-url` measures that server, alone or next to `--providers`. Its results
|
|
107
|
+
are under `openai-compatible`.
|
|
108
|
+
- The MCP server can use an OpenAI-compatible server. `NLP2SQL_LLM_BASE_URL` selects it,
|
|
109
|
+
`NLP2SQL_LLM_MODEL` is the model to ask for and `NLP2SQL_LLM_API_KEY` its key, if it has
|
|
110
|
+
one. `OPENAI_API_KEY` is not sent there. Before, the MCP server could not choose a model.
|
|
111
|
+
- Docs: [OpenAI-compatible endpoints](https://github.com/luiscarbonel1991/nlp2sql/blob/main/docs/CONFIGURATION.md#openai-compatible-endpoints),
|
|
112
|
+
with an Ollama example and how to set the context size of a local model.
|
|
113
|
+
|
|
114
|
+
### Changed
|
|
115
|
+
- **The Gemini adapter uses the `google-genai` SDK** (`google-genai>=1.51.0`) instead of
|
|
116
|
+
`google-generativeai`, which Google has deprecated. The dependency is still part
|
|
117
|
+
of the core install and of the `gemini` and `all-providers` extras. Installs no longer
|
|
118
|
+
pull `grpcio`, `protobuf` or `google-api-core`. Pip installs `google-genai` 2.33 on
|
|
119
|
+
Python 3.10 and 3.0 or later on Python 3.11 and up.
|
|
120
|
+
- Requests go to the stable `v1` API version on every SDK release. The SDK's own default
|
|
121
|
+
is `v1beta` up to 2.x and `v1` from 3.0.
|
|
122
|
+
- The system prompt is sent as a system instruction, and the answer is requested as JSON
|
|
123
|
+
(`response_mime_type="application/json"`).
|
|
124
|
+
- The adapter still runs requests in a worker thread. The SDK's async client keeps
|
|
125
|
+
connections bound to the event loop that opened them, so one adapter used from two
|
|
126
|
+
`asyncio.run()` calls failed with "Event loop is closed".
|
|
127
|
+
- **The default Gemini model is `gemini-3.8-flash`**, with `thinking_level="low"`. Other
|
|
128
|
+
models keep their own thinking default; `gemini-3.6-flash` and other models can still be
|
|
129
|
+
pinned with `ProviderConfig(model=...)`.
|
|
130
|
+
- **Behavior change:** the Gemini adapter no longer sends `temperature` or `candidate_count`.
|
|
131
|
+
Google deprecated `temperature` for Gemini 3.6 and later (ignored now, an error in future
|
|
132
|
+
models), and `candidate_count` is unsupported since Gemini 3. A `temperature` passed to
|
|
133
|
+
`GeminiAdapter` is kept and logged at INFO, like the Anthropic adapter does.
|
|
134
|
+
- The Gemini adapter estimates prompt tokens locally (about 4 characters per token), like the
|
|
135
|
+
Anthropic adapter. It called the countTokens API before every question, a blocking network
|
|
136
|
+
round trip inside `generate_query`.
|
|
137
|
+
- **Behavior change:** the LLM review of a query (`llm_validation=True`, or `validate()`)
|
|
138
|
+
gives a result with the same keys for every provider: `is_valid`, `errors` and
|
|
139
|
+
`warnings`. With the Anthropic and Gemini adapters the problems were listed under
|
|
140
|
+
`issues`. They are now under `errors`, as with OpenAI and as `docs/API.md` says.
|
|
141
|
+
`AIProviderPort.validate_query` documents this contract, and the service holds every
|
|
142
|
+
provider's answer to it. A custom provider that answers with `issues` keeps working.
|
|
143
|
+
|
|
144
|
+
### Fixed
|
|
145
|
+
- `nlp2sql query` and `nlp2sql benchmark` no longer hand the chat key to the OpenAI embeddings
|
|
146
|
+
of the few-shot examples when the chat provider is not OpenAI. With `--provider anthropic
|
|
147
|
+
--embedding-provider openai` and examples, the Anthropic key was sent to OpenAI as its key.
|
|
148
|
+
Those embeddings now use `OPENAI_API_KEY`.
|
|
149
|
+
- Gemini thinking tokens are counted. `tokens_used` now includes them, and the response
|
|
150
|
+
metadata reports `thinking_tokens`. They are billed as output, but the old adapter counted
|
|
151
|
+
only prompt and answer tokens.
|
|
152
|
+
- Network failures that httpx reports as `ConnectError`, `ReadError` or `RemoteProtocolError`
|
|
153
|
+
are treated as transient and retried. Their class names do not contain "Connection", so
|
|
154
|
+
they ended the question at once. The `google-genai` SDK raises them unwrapped.
|
|
155
|
+
- A Gemini prompt blocked by a safety filter raises `ProviderRequestError` that names the
|
|
156
|
+
block reason, instead of "Gemini returned no response candidates".
|
|
157
|
+
- The OpenAI, OpenAI embedding and Anthropic adapters work when one adapter is used from
|
|
158
|
+
more than one event loop, for example with one `asyncio.run()` per question. With
|
|
159
|
+
`openai` 3.x and `anthropic` 2.x, the SDKs' async clients keep connections bound to the
|
|
160
|
+
event loop that opened them. The OpenAI adapters failed every other call with "Event loop
|
|
161
|
+
is closed". The Anthropic adapter lost one attempt and a retry delay on each new loop, and
|
|
162
|
+
failed when the SDK's retries were off. The adapters now call the SDKs' sync clients in a
|
|
163
|
+
worker thread, like the Gemini adapter. Cancelling a question no longer cancels its HTTP
|
|
164
|
+
request, which runs to the end in the thread. Code that replaced `adapter.client` should
|
|
165
|
+
pass an `openai.OpenAI` or `anthropic.Anthropic` client instead of the async one.
|
|
166
|
+
- An LLM review that could not be done is no longer reported as an approval. When the
|
|
167
|
+
validation call of the Anthropic or Gemini adapter failed (a network error, a rate limit,
|
|
168
|
+
an answer that was not JSON), the result said `is_valid: True`, `nlp2sql query` printed
|
|
169
|
+
"SQL validation: Passed", and in `generate_only` mode the result was cached as valid.
|
|
170
|
+
The result is now `is_valid: False`, with the reason in `errors` and in the new
|
|
171
|
+
`validation["llm_validation_error"]`. The question keeps its SQL.
|
|
172
|
+
- A custom provider that raises from `validate_query` no longer fails the whole question,
|
|
173
|
+
and `validate()` returns the result above instead of raising `ValidationException`.
|
|
174
|
+
- `result.validation["errors"]` no longer raises `KeyError` when the Anthropic or Gemini
|
|
175
|
+
review is on.
|
|
176
|
+
- `nlp2sql query` prints the errors of an invalid query. It printed an empty list unless
|
|
177
|
+
the Anthropic or Gemini review was on, because it read `issues`.
|
|
178
|
+
- An error or warning that the reviewing model writes as an object is reported by its text.
|
|
179
|
+
`"warnings": [{"message": "no LIMIT"}]` came out as the text of a Python dict,
|
|
180
|
+
`"{'message': 'no LIMIT'}"`. Small local models answer this way more often.
|
|
181
|
+
- The three provider adapters answer `validate_query` by the port's contract when they are
|
|
182
|
+
called directly too. The Anthropic and Gemini adapters reported a failed call as valid,
|
|
183
|
+
and treated a JSON answer without `is_valid` as valid. An answer that is not JSON, or has
|
|
184
|
+
no boolean `is_valid`, is now a review that could not be done, and its tokens are still
|
|
185
|
+
counted. `OpenAIAdapter` reports a failed call the same way: `llm_validation_error`, and
|
|
186
|
+
"LLM validation unavailable: ..." in `errors` instead of "Validation failed: ...". The
|
|
187
|
+
Anthropic and Gemini adapters no longer add default `suggestions` and `complexity` keys.
|
|
188
|
+
- The MCP server asks for `mcp<2`. It uses the 1.x API of the `mcp` SDK, and with 2.x, which
|
|
189
|
+
`pip install nlp2sql mcp` installs today, it failed at import with "No module named
|
|
190
|
+
'mcp.server.fastmcp'". The README installs `"mcp<2"` too.
|
|
191
|
+
|
|
25
192
|
## [0.2.0rc20] - 2026-11-08
|
|
26
193
|
|
|
27
194
|
### Security
|
|
@@ -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
|
|
@@ -25,7 +25,7 @@ Requires-Dist: azure-identity>=1.15.0
|
|
|
25
25
|
Requires-Dist: boto3>=1.34.0
|
|
26
26
|
Requires-Dist: click>=8.0.0
|
|
27
27
|
Requires-Dist: faiss-cpu>=1.7.4
|
|
28
|
-
Requires-Dist: google-
|
|
28
|
+
Requires-Dist: google-genai>=1.51.0
|
|
29
29
|
Requires-Dist: greenlet>=3.2.3
|
|
30
30
|
Requires-Dist: httpx>=0.25.0
|
|
31
31
|
Requires-Dist: numpy>=1.24.0
|
|
@@ -47,7 +47,7 @@ Provides-Extra: all-embeddings
|
|
|
47
47
|
Requires-Dist: sentence-transformers>=2.5.0; extra == 'all-embeddings'
|
|
48
48
|
Provides-Extra: all-providers
|
|
49
49
|
Requires-Dist: anthropic>=0.18.0; extra == 'all-providers'
|
|
50
|
-
Requires-Dist: google-
|
|
50
|
+
Requires-Dist: google-genai>=1.51.0; extra == 'all-providers'
|
|
51
51
|
Provides-Extra: anthropic
|
|
52
52
|
Requires-Dist: anthropic>=0.18.0; extra == 'anthropic'
|
|
53
53
|
Provides-Extra: dev
|
|
@@ -66,14 +66,9 @@ Provides-Extra: embeddings-local
|
|
|
66
66
|
Requires-Dist: sentence-transformers>=2.5.0; extra == 'embeddings-local'
|
|
67
67
|
Provides-Extra: embeddings-openai
|
|
68
68
|
Provides-Extra: gemini
|
|
69
|
-
Requires-Dist: google-
|
|
70
|
-
Provides-Extra: mssql
|
|
71
|
-
Requires-Dist: pymssql>=2.2.0; extra == 'mssql'
|
|
69
|
+
Requires-Dist: google-genai>=1.51.0; extra == 'gemini'
|
|
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
|
|
@@ -114,8 +109,8 @@ The library is designed for both simple schemas and large warehouses, but all pu
|
|
|
114
109
|
- **Read-only execution**: queries pass a safety check and run in read-only transactions; connect with a database user that can only read (see [SECURITY.md](https://github.com/luiscarbonel1991/nlp2sql/blob/main/SECURITY.md#security-best-practices))
|
|
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
|
-
- **Multiple providers**: OpenAI, Anthropic, and Gemini built in
|
|
118
|
-
- **Database support**: PostgreSQL
|
|
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()`
|
|
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]
|
|
@@ -352,10 +351,27 @@ postgresql://testuser:testpass@localhost:5432/testdb
|
|
|
352
351
|
|----------|---------------|--------------|------------|----------|
|
|
353
352
|
| OpenAI | `gpt-5.6-luna` | 1.05M (922K input) | 128K | Fast, low-cost general purpose usage |
|
|
354
353
|
| Anthropic | `claude-sonnet-5` | 1M | 128K | Larger schemas and long prompts |
|
|
355
|
-
| Gemini | `gemini-3.
|
|
354
|
+
| Gemini | `gemini-3.8-flash` | 1M | 64K | High-volume and very large contexts |
|
|
356
355
|
|
|
357
356
|
Defaults are pinned snapshot IDs, not floating aliases. Override any of them through `ProviderConfig(model=...)`; for example `gpt-5.6-terra` is the higher-quality OpenAI option.
|
|
358
357
|
|
|
358
|
+
### Local and Self-Hosted Models
|
|
359
|
+
|
|
360
|
+
The OpenAI provider can use any server that speaks OpenAI's Chat Completions API, such as Ollama, vLLM or a gateway. Pass its address as `base_url`:
|
|
361
|
+
|
|
362
|
+
```python
|
|
363
|
+
nlp = await nlp2sql.connect(
|
|
364
|
+
"postgresql://testuser:testpass@localhost:5432/testdb",
|
|
365
|
+
provider=ProviderConfig(
|
|
366
|
+
provider="openai",
|
|
367
|
+
base_url="http://localhost:11434/v1", # a local Ollama
|
|
368
|
+
model="llama3.2",
|
|
369
|
+
),
|
|
370
|
+
)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
No OpenAI key is needed, and the one in your environment is not sent to that server. See [OpenAI-compatible endpoints](https://github.com/luiscarbonel1991/nlp2sql/blob/main/docs/CONFIGURATION.md#openai-compatible-endpoints) for keys, request parameters, embeddings and the context size of local models.
|
|
374
|
+
|
|
359
375
|
## Lower-Level API
|
|
360
376
|
|
|
361
377
|
`connect()` is the recommended path. Lower-level entry points still exist for advanced wiring:
|
|
@@ -34,8 +34,8 @@ The library is designed for both simple schemas and large warehouses, but all pu
|
|
|
34
34
|
- **Read-only execution**: queries pass a safety check and run in read-only transactions; connect with a database user that can only read (see [SECURITY.md](https://github.com/luiscarbonel1991/nlp2sql/blob/main/SECURITY.md#security-best-practices))
|
|
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
|
-
- **Multiple providers**: OpenAI, Anthropic, and Gemini built in
|
|
38
|
-
- **Database support**: PostgreSQL
|
|
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, 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]
|
|
@@ -272,10 +276,27 @@ postgresql://testuser:testpass@localhost:5432/testdb
|
|
|
272
276
|
|----------|---------------|--------------|------------|----------|
|
|
273
277
|
| OpenAI | `gpt-5.6-luna` | 1.05M (922K input) | 128K | Fast, low-cost general purpose usage |
|
|
274
278
|
| Anthropic | `claude-sonnet-5` | 1M | 128K | Larger schemas and long prompts |
|
|
275
|
-
| Gemini | `gemini-3.
|
|
279
|
+
| Gemini | `gemini-3.8-flash` | 1M | 64K | High-volume and very large contexts |
|
|
276
280
|
|
|
277
281
|
Defaults are pinned snapshot IDs, not floating aliases. Override any of them through `ProviderConfig(model=...)`; for example `gpt-5.6-terra` is the higher-quality OpenAI option.
|
|
278
282
|
|
|
283
|
+
### Local and Self-Hosted Models
|
|
284
|
+
|
|
285
|
+
The OpenAI provider can use any server that speaks OpenAI's Chat Completions API, such as Ollama, vLLM or a gateway. Pass its address as `base_url`:
|
|
286
|
+
|
|
287
|
+
```python
|
|
288
|
+
nlp = await nlp2sql.connect(
|
|
289
|
+
"postgresql://testuser:testpass@localhost:5432/testdb",
|
|
290
|
+
provider=ProviderConfig(
|
|
291
|
+
provider="openai",
|
|
292
|
+
base_url="http://localhost:11434/v1", # a local Ollama
|
|
293
|
+
model="llama3.2",
|
|
294
|
+
),
|
|
295
|
+
)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
No OpenAI key is needed, and the one in your environment is not sent to that server. See [OpenAI-compatible endpoints](https://github.com/luiscarbonel1991/nlp2sql/blob/main/docs/CONFIGURATION.md#openai-compatible-endpoints) for keys, request parameters, embeddings and the context size of local models.
|
|
299
|
+
|
|
279
300
|
## Lower-Level API
|
|
280
301
|
|
|
281
302
|
`connect()` is the recommended path. Lower-level entry points still exist for advanced wiring:
|
|
@@ -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
|