MCPcopy Index your code
hub / github.com/adaptive-scale/dbchaos

github.com/adaptive-scale/dbchaos @v0.4.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.4.4 ↗ · + Follow
62 symbols 134 edges 22 files 3 documented · 5% updated 2y ago★ 4383 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

DBChaos

Stress-test your database with pre-defined queries, generate synthetic data in your database. Validate slow and expensive queries that breaks your database.

Features

  • Synthetic Event Generation
  • Synthentic Data Generation

Installation

go install github.com/adaptive-scale/dbchaos@v0.4.3

Supported Databases

Run your first test

Create a file named config.yaml with the following content:

dbType: postgres
connection: "host=localhost port=5432 user=postgres password=postgres dbname=postgres sslmode=disable"
query: |
  SELECT pg_database.datname as "Database", pg_size_pretty(pg_database_size(pg_database.datname)) as "Size"
  FROM pg_database;
parallelRuns: 100
runFor: 30m

For MongoDB, the connection string should be in the following format:

dbType: mongodb
connection: "mongodb://root:example@localhost:27017/"
query: |
    {"insert": "users", "documents": [{ "user": "abc123", "status": "A" }]}
parallelRuns: 100
runFor: 30m
dbName: users

To run the above config file:

dbchaos runTest 

Run bunch of queries in parallel

Create a file called scenario.yaml with the following content:

dbType: mysql
connection: "root:root@tcp(host:port)/db"
scenarios:
  - query: select * from information_schema.statistics
    parallelRuns: 10000
    runFor: 15m
  - query: |
      SELECT table_schema "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) "Size (MB)"
      FROM information_schema.tables
      GROUP BY table_schema;
    parallelRuns: 10000
    runFor: 15m

To run the above scenario file:

dbchaos runScenario 

MongoDB Specific:

Example scenario.yaml file:

dbType: mongodb
connection: "mongodb://root:example@localhost:27017/"
scenarios:
  - query: '{"insert": "users", "documents": [{ "user": "abc123", "status": "A" }]}'
    parallelRuns: 10000
    runFor: 15m
dbName: users   #(MongoDB only)

Static Synthetic Data Generation

DBChaos can also generate full schema and synthetic data for your database.

connection: 
  dbType: postgres
  connection: "host=localhost port=5432 user=postgres password=postgres dbname=postgres sslmode=disable"
dryRun: false
schema: 
  numberOfSchema: 10
  generateTables: true
  language: en
tables:
  numberOfTables: 10
  minColumns: 5
  maxColumns: 10
  populateTable: true
rows:
  minRows: 100
  maxRows: 1000

Save above config as config.yaml and run the following command:

dbchaos generate

Synthetic Data Generation With GPT

DBChaos can also generate full schema and synthetic data for your database using GPT/LLM models.

connection: 
  dbType: postgres
  connection: "host=localhost port=5432 user=postgres password=postgres dbname=postgres sslmode=disable"
dryRun: false
provider: openai
model: gpt-3.5-turbo
schema_type: webshop # can be anything word like ecommerce, webshop, hospital etc

Also, you have to set your OpenAI API key as an environment variable OPENAI_API_KEY.

Save above config as config.yaml and run the following command:

dbchaos generateWithLLM

This will generate the schemas, insert commands and persist it in the database.

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 23
Struct 19
Function 16
TypeAlias 3
Interface 1

Languages

Go100%

Modules by API surface

pkg/config/generation.go30 symbols
pkg/config/simple_config.go4 symbols
pkg/config/scenario.go3 symbols
pkg/config/generate_with_llm.go3 symbols
pkg/utils/random.go2 symbols
pkg/runner/runner.go2 symbols
pkg/openai/query.go2 symbols
pkg/generate/social_media.go2 symbols
pkg/config/connection.go2 symbols
cmd/root.go2 symbols
pkg/openai/query_test.go1 symbols
pkg/namesgenerator/namesgenerator.go1 symbols

Datastores touched

(mongodb)Database · 1 repos

For agents

$ claude mcp add dbchaos \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page