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.3.0a0.tar.gz (27.4 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.3.0a0-py3-none-any.whl (27.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qseed-0.3.0a0.tar.gz
Algorithm Hash digest
SHA256 8b69fc0538aed64d571ba64026cdb4e21447f17665cc002abebdb424f955eff5
MD5 1adab34443f704808d9061f76babc46b
BLAKE2b-256 82ffe3b1f0d1f5cdbf7382fc9ddad23d8f820604ce685249a527279a2e1dfcdf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qseed-0.3.0a0-py3-none-any.whl
  • Upload date:
  • Size: 27.9 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.3.0a0-py3-none-any.whl
Algorithm Hash digest
SHA256 969248b8d7eede18b24556413390052fa7271e1d26f380b769e6ff5a01a3f922
MD5 095451bf60b7cc82f12a63913df6c7ca
BLAKE2b-256 53dc250d0dd85c8f88ed28bbc7b9e76b496d1dd4280a57674d40224ba02db32c

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