Skip to main content

A Python package that allows to use the CLI and Natural Language processing to write MySQL queries.

Project description

README.md

Natural Language MySQL Schema Creator

Python Version

License: MIT

A Python package that converts natural language commands into MySQL database schemas through both CLI and interactive modes.

Features

  • 🗣️ Natural language processing for schema creation

  • 🔒 Secure database connections with parameterized queries

  • 💻 Interactive CLI mode with guided prompts

  • 📝 Support for both text input and file input

  • 🛠️ Schema validation and error recovery

  • 🔄 Connection pooling for better performance

  • 🧪 Dry-run mode for SQL preview

Installation

bash

pip install MySQL_NLP_CLI

python -m spacy download en_core_web_sm

Usage

Command Line Interface

bash

Natural language input

mysql_nlp_cli -t "Create database 'ecommerce' with table users (id int primary key)" -u root

File input

mysql_nlp_cli -f schema.txt -u root --dry-run

Interactive mode

mysql_nlp_cli -i -u root

Natural Language Examples

Input:

text

Create database 'inventory' with tables:

  • products (id int primary key, name varchar(255) not null, price decimal(10,2))

  • orders (order_id int auto_increment, product_id int, quantity int)

Generated SQL:

sql

CREATE DATABASE inventory CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci;

USE inventory;

CREATE TABLE products (

id INT PRIMARY KEY,

name VARCHAR(255) NOT NULL,

price DECIMAL(10,2)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE orders (

order_id INT AUTO_INCREMENT,

product_id INT,

quantity INT

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Interactive Mode Demo

text

$ mysql_nlp_cli -i -u root

=== MySQL Schema Creator ===

Database name: my_shop

Add table? [Y/n]: y

Table name: customers

Column name: id

Data type: INT

Primary key? [y/N]: y

Nullable? [Y/n]: n

Add another column? [Y/n]: y

Column name: email

Data type: VARCHAR

Length: 255

Nullable? [Y/n]: n

Unique constraint? [y/N]: y

[1] Continue to database creation

[2] Preview SQL

[3] Cancel

Choice: 2

Generated SQL:

...

Configuration

Environment variables (optional):

env

MYSQL_HOST=localhost

MYSQL_PORT=3306

MYSQL_USER=root

Features

  • Natural Language Processing

    • Automatic type conversion

    • Constraint detection (primary key, nullability)

    • Multi-table support

    • Complex column definitions

  • Security

    • Password masking

    • SQL injection prevention

    • Connection encryption

    • Schema validation

  • Interactive Mode

    • Step-by-step guidance

    • Real-time validation

    • Error recovery

    • SQL preview

Contributing

  1. Fork the repository

  2. Create your feature branch (git checkout -b feature/awesome-feature)

  3. Commit your changes (git commit -am 'Add awesome feature')

  4. Push to the branch (git push origin feature/awesome-feature)

  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Troubleshooting

Q: Getting "Language model not found" error

bash

python -m spacy download en_core_web_sm

Q: MySQL connection issues

  • Verify MySQL server is running

  • Check firewall settings

  • Validate user permissions

Q: Schema validation errors

  • Ensure names follow [a-zA-Z0-9_] pattern

  • Check for duplicate primary keys

  • Verify supported data types

This documentation provides users with comprehensive information about the package while maintaining professional formatting and clear organization. The README includes:

  1. Badges for quick info

  2. Feature highlights

  3. Installation instructions

  4. Usage examples

  5. Configuration guidance

  6. Development guidelines

  7. Troubleshooting common issues

  8. License information

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mysql_nlp_cli-1.0.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

MySQL_NLP_CLI-1.0.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file mysql_nlp_cli-1.0.0.tar.gz.

File metadata

  • Download URL: mysql_nlp_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for mysql_nlp_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dc3a3b373238e69c6cde97a378919174c2228dc0e6e4aff6682c2ef3044e9a74
MD5 42fdd28d121b545ef62c461711a60b5d
BLAKE2b-256 c53268ef7d654da74a02b276ebe980829bccf57acb0ec3d292e9297447b15877

See more details on using hashes here.

File details

Details for the file MySQL_NLP_CLI-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: MySQL_NLP_CLI-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for MySQL_NLP_CLI-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 34d239844b455c3a1268f18ac4ad69883bab8a36878954c7f1eb39afc12c7fdc
MD5 3cd1e489c0efe9cc5ddd8198dba5bd5b
BLAKE2b-256 4a30521b9748c3607c0ce0bece884890b0f566e833f3c6bda74b6b4090062d36

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page