Metadata-Version: 2.4
Name: seedbase
Version: 0.2.0
Summary: Generate realistic test data for your databases. Schema-aware, relationship-preserving, privacy-safe.
Author-email: Seedbase <contact@seedba.se>
License: MIT
Project-URL: Homepage, https://seedba.se
Project-URL: Documentation, https://docs.seedba.se
Project-URL: Repository, https://github.com/marcelglaeser/seedbase-python
Project-URL: Changelog, https://github.com/marcelglaeser/seedbase-python/blob/master/CHANGELOG.md
Keywords: testing,test-data,database,synthetic-data,data-generation
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: certs
Requires-Dist: certifi; extra == "certs"
Provides-Extra: database
Requires-Dist: sqlalchemy>=2.0; extra == "database"
Dynamic: license-file

<p align="center">
  <img src="https://seedba.se/seedbase-logo-256.png" alt="Seedbase" width="120" />
</p>

# Seedbase

Generate realistic, relationship-preserving, privacy-safe test data for your databases, and pull it straight into your local or CI database.

Seedbase lives on [seedba.se](https://seedba.se): you model (or import) a schema there, generate datasets, and use this package to pull them into Postgres, MySQL, SQLite and more. Schema-aware, foreign-key-correct, reproducible by seed.

Create a **free** account at [seedba.se/register](https://seedba.se/register), no credit card. The free tier is enough to generate full, foreign-key-consistent datasets.

## Install

```bash
pip install seedbase
```

Zero dependencies, pure Python (3.10+).

## CLI quickstart

```bash
seedbase login                 # opens the browser, stores a token
seedbase init                  # creates .seedbase.json (project + target DB)
seedbase generate --seed 42    # trigger a generation on the platform
seedbase pull all              # write schema + data into your target DB
```

The CLI is pull-oriented: schema and datasets live on the platform, you pull them into your database. Other commands: `projects`, `generations`, `connections`, `pull schema|data|subset`, `mask`, `db-push`, `diff`, `export config`, `import config`.

## Python SDK

```python
from seedbase import SeedbaseClient

client = SeedbaseClient(token="dr_sk_...")          # or from ~/.seedbase/config.json
gen = client.generate(project_id, seed=42, wait=True)
data = client.download(gen["id"], fmt="sql")
```

## pytest fixtures

Seedbase ships a pytest plugin, so realistic, foreign-key-consistent test data is one fixture away. pytest fixtures are dependency injection, so this is your test data, injected.

**Inject a populated test database** (the headline). The target database needs its schema already migrated; SeedBase fills it with FK-consistent data and cleans up after the session. Needs SQLAlchemy 2.0 (`pip install "seedbase[database]"`):

```python
import sqlalchemy

def test_pagination(seeded_database):
    # seeded_database is a live connection to a DB full of realistic data
    rows = seeded_database.execute(
        sqlalchemy.text("SELECT email FROM users LIMIT 5")
    ).fetchall()
    assert all("@" in email for (email,) in rows)
```

**Inject the rows directly** (no database, no driver):

```python
def test_user_shape(seeded_rows):
    # {table_name: [row_dict, ...]}, in foreign-key-safe order
    assert seeded_rows["users"][0]["email"]
```

**Raw bytes** (SQL/CSV/JSON dump) if you want to load it yourself:

```python
def test_dump(seeded_data):
    assert seeded_data
```

Deterministic per seed, so the same seed gives the same data and your tests are reproducible. Configure via env (`SEEDBASE_TOKEN`, `SEEDBASE_PROJECT`, `SEEDBASE_SEED`, `SEEDBASE_TEST_DATABASE_URL`) or `pytest.ini` (`seedbase_project`, `seedbase_seed`, `seedbase_rows`, `seedbase_database_url`). All fixtures skip with a helpful message if the project or credentials are missing, so they never break a suite that has not configured them.

## Links

- Website: https://seedba.se
- Docs: https://seedba.se/docs
- API keys: https://seedba.se/settings?tab=api-keys

MIT licensed.
