Skip to main content

Generate test data from MSSQL stored procedures — automatically

Project description

qseed

Generate test data from your MSSQL stored procedures — automatically.

qseed connects to your MSSQL database, fetches all DDL needed by a stored procedure or query, calls the datagen API, and writes INSERT statements to stdout, a file, or your clipboard.


Quick Start

# Point to your datagen-core API
qseed config set-api https://datagen.aldimhr.dev

# Add your database (password stored in OS keyring)
qseed config add default

# Generate 10 rows for a stored procedure
qseed --procedure GetCustomerOrders --rows 10

# Pipe directly to sqlcmd
qseed --procedure GetCustomerOrders --rows 50 | sqlcmd -S myserver -d mydb

Or skip the config file and pass everything on the command line:

qseed \
  --server mydb.company.com --database SalesDB --user sa --password secret \
  --procedure GetCustomerOrders --rows 10 -o test_data.sql

Installation

From PyPI

pip install qseed

From Repository

git clone https://github.com/aldimhr/qseed.git
cd qseed
pip install .

Ubuntu / Raspberry Pi

pymssql requires FreeTDS:

sudo apt-get install -y python3-dev freetds-dev freetds-bin libssl-dev
pip install qseed

macOS

brew install freetds
pip install qseed

Commands

run (default)

Generate INSERT statements. The run subcommand is optional — if you pass --procedure, --sql, or --sql-file, it's implied automatically.

# From a stored procedure
qseed --procedure GetCustomerOrders --rows 10

# From raw SQL
qseed --sql "SELECT * FROM Orders WHERE Status = 'ACTIVE'" --rows 5

# From a .sql file
qseed --sql-file query.sql --rows 20

# Explicit run (same as above)
qseed run --procedure GetCustomerOrders --rows 10

Connection options

Flag Description
--server HOST MSSQL server hostname or IP
--port PORT Port (default: 1433)
--database DB Database name
--user USER SQL Server login
--password PASS Password
--password-env VAR Read password from environment variable
--profile NAME Use a saved connection profile

Generation options

Flag Description
-r, --rows N Target row count (default: 10)
-p, --param @N=V Parameter binding, repeatable
--schema SCHEMA Schema for object lookup (default: dbo)

Sub-procedure handling

Flag Description
--recursive Discover tables from sub-procedures called via EXEC
--max-depth N Max recursion depth (default: 5)
--no-sub-proc-warning Suppress the sub-procedure warning

Output options

Flag Description
-o, --output PATH Write to file (default: stdout)
--copy Copy to clipboard
--open Open in $DATAGEN_EDITOR or $EDITOR

Debug options

Flag Description
--dry-run Fetch DDL and print it without calling the API
--show-ddl Print fetched DDL alongside the output
--timeout N DB connection timeout in seconds (default: 30)
--api-timeout N API call timeout in seconds (default: 120)

list

Browse stored procedures in the database.

qseed list
qseed list --schema sales
qseed list --search Customer
qseed list --json

config

Manage connection profiles.

qseed config add production      # Interactive prompts
qseed config list                # All profiles (passwords masked)
qseed config show default        # Profile details
qseed config test production     # Test DB + API reachability
qseed config remove old-profile  # Remove a profile
qseed config set-default production  # Set the default profile
qseed config set-api https://... # Set the API URL

version

qseed version

Configuration

Config File

~/.qseed/config.json:

{
  "api_url": "https://datagen.aldimhr.dev",
  "api_timeout": 120,
  "default_profile": "default",
  "profiles": {
    "default": {
      "server": "localhost",
      "port": 1433,
      "database": "MyDatabase",
      "user": "sa",
      "password_keyring": true,
      "schema": "dbo"
    }
  }
}

Password Storage

Passwords are stored in your OS keyring (keyring package):

  • macOS: Keychain
  • Linux: libsecret / GNOME Keyring / KWallet
  • Windows: Windows Credential Manager

If the keyring is unavailable, the CLI prompts for the password on each run.

Environment Variables

All settings can be set via environment variables (no config file needed):

export DATAGEN_API_URL=https://datagen.aldimhr.dev
export DATAGEN_SERVER=mydb.company.com
export DATAGEN_DATABASE=SalesDB
export DATAGEN_USER=datagen_readonly
export DATAGEN_PASSWORD=$DB_PASSWORD

Env vars take priority over the config file. CLI flags take priority over env vars.

CI/CD Usage

DATAGEN_API_URL=https://datagen.aldimhr.dev \
DATAGEN_SERVER=mydb.company.com \
DATAGEN_DATABASE=SalesDB \
DATAGEN_USER=datagen_readonly \
DATAGEN_PASSWORD=${{ secrets.DB_PASSWORD }} \
qseed --procedure GetCustomerOrders --rows 50 -o test_data.sql

How It Works

qseed                    datagen-core (API)
─────────────                  ──────────────────
1. Connect to your MSSQL
2. Fetch SP DDL + table DDL
   + view DDL
3. POST /generate ──────────► 4. Parse constraints
                              5. Generate INSERTs
6. Write output ◄────────────  (plain SQL text)
   (stdout / file / clipboard)

Credentials never leave your machine. Only DDL text is sent to the API.


Dependencies

  • pymssql >=2.3 — MSSQL connection
  • requests >=2.31 — HTTP calls to datagen-core
  • keyring >=25.0 — OS password storage
  • pyperclip >=1.8 — Clipboard output

Development

git clone https://github.com/aldimhr/qseed.git
cd qseed
pip install -e ".[dev]"
python -m datagen_cli --help

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

qseed-0.2.0a0.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

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

qseed-0.2.0a0-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file qseed-0.2.0a0.tar.gz.

File metadata

  • Download URL: qseed-0.2.0a0.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for qseed-0.2.0a0.tar.gz
Algorithm Hash digest
SHA256 ef1e8dcbf30c2a49a10415bbd09af686fdd46a4b844a80702d167de5ab187a0e
MD5 cf7a906a2f4bcc4eab7847087c9e26d0
BLAKE2b-256 d9c96d706d743b561a9253bd9e0346674fc50973e062279e584e52f3e6e17e0a

See more details on using hashes here.

File details

Details for the file qseed-0.2.0a0-py3-none-any.whl.

File metadata

  • Download URL: qseed-0.2.0a0-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for qseed-0.2.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb375051d3861aca394159a6067f264ebd576a1f6798875d1dc448ac014bfc72
MD5 21711b8c78e8948a576f5f6b546c48da
BLAKE2b-256 d61fb7a97038346f1b3467a86b3ea4b68ae556c55d7d01e09d2a741fef217c54

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