Skip to main content

Fake your PostgreSQL database content with utmost ease using an AI agent

Project description

Filgood

“fil” came from the arabic transliteration (فيل) - meaning elephant!

Utility to populate a database only knowing the actual schemas. This program only operate with Postgres. Sufficient right will be required (SCHEMA CREATE / TABLE CREATE & Inspect pg_catalog).

The library require asyncio. We are bound to the asyncpg connector, and we support no other connector for the time being.

Quick start

Using the CLI

FilGood come with a CLI! It is really easy to use, for your convenience.

$ filgood -h
usage: filgood [-h] [-i INCREASE] [-s SCHEMA] [-t TABLE] [--no-cache] [--skip-empty] [-v] database

LLM agent for filling a database with fake records

positional arguments:
  database              Postgres database DSN to be used

options:
  -h, --help            show this help message and exit
  -i INCREASE           Percentage increase or flat row count target for data injection
  -s SCHEMA, --schema SCHEMA
                        Target a specific schema
  -t TABLE, --table TABLE
                        Target a specific table
  --no-cache            Disable the cache (LLM)
  --skip-empty          Skip empty table
  -v, --verbose         Enable advanced debugging

For example, running: filgood postgres://postgres:postgres@localhost:5555/postgres -i 1000 will increase every table by a thousand records!

Or, running: filgood postgres://postgres:postgres@localhost:5555/postgres -i 300% will increase every table by adding three times more records.

Starting code

Here is a minimal code snippet to get started. This will increase by 300% (or 3 times the current amount of rows) every detected tables in every accessible schemas.

import asyncio

from filgood import DatabaseFaker, GrowthStrategy

async def main() -> None:
    async with DatabaseFaker(
        "postgres://postgres:postgres@localhost/tracktor",
        openai_key="sk-proj-gm...",  # either provide the key here or set OPENAI_API_KEY environment variable first.
    ) as db_faker:
        await db_faker.load(
            strategy=GrowthStrategy.BY_PERCENT_INCREASE,
            increase=300,
        )

if __name__ == "__main__":
    asyncio.run(main())

Exclude schemas

Don't worry, we already excluded system schemas. Moreover, you may also exclude some schemas yourself.

from filgood import DatabaseFaker

async def main() -> None:
    async with DatabaseFaker(
        "postgres://postgres:postgres@localhost/tracktor",
        excluded_schemas=["sensible_schema_a", "useless_schema_b",]  # you get the idea!
    ) as db_faker:
        ...

Focusing on schema or table or both

Here's how to keep focused on a target schema:

from filgood import DatabaseFaker

async def main() -> None:
    async with DatabaseFaker(
        "postgres://postgres:postgres@localhost/tracktor",
    ) as db_faker:
        await db_faker.load(target_schema="xyz")

And now a specific table without a specific schema:

from filgood import DatabaseFaker

async def main() -> None:
    async with DatabaseFaker(
        "postgres://postgres:postgres@localhost/tracktor",
    ) as db_faker:
        await db_faker.load(target_table="abc")

Of course, you may set both schema and table to ensure a really specific case.

Caching

In order to avoid depleting your OpenAI API credit, we made a tiny caching layer that just works. You can expect the bare minimum amount of requests to OpenAI! Feel free to inspect at will the generated cache file that should be named .filgood.json in your pwd or $HOME (via CLI).

Performance

You may increase at any time the database pool connection by setting the database_pool_size parameter.

from filgood import DatabaseFaker

async def main() -> None:
    async with DatabaseFaker(
        "postgres://postgres:postgres@localhost/tracktor",
        database_pool_size=100,
    ) as db_faker:
        await db_faker.load(target_table="abc")

Warnings / Disclaimers

That's the tough section, unfortunately not everything "automagic" is pretty inside. Here is some of our warnings about this:

  • FilGood does not watch for the remaining disk space left on your device. Don't go south with the row insertions!
  • We rely on a LLM codegen, and we trust the given generated code blindly. It would be wise to only use a provider/model you know is guarded by a trusted third party.
  • The RAM usage may spike depending on your initial request.
  • Can often fail on really complex databases. We did our best.

We think that you get the general idea. Be careful. It's a nice proof of concept, but we shouldn't expect too much out of it.

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

filgood-0.1.1.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

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

filgood-0.1.1-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file filgood-0.1.1.tar.gz.

File metadata

  • Download URL: filgood-0.1.1.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for filgood-0.1.1.tar.gz
Algorithm Hash digest
SHA256 23fc24f5068261932a3a6a9a095ed8dd991ad09bb5b4ae6585627ec2ee0523e3
MD5 6474fd20cf2d8e4a3858ea0120345aae
BLAKE2b-256 fc531f6c14daaead8f80cef989849751a46954148b0c2bff0f65bf2033483eec

See more details on using hashes here.

File details

Details for the file filgood-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: filgood-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for filgood-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9ac91ce487609b0772cce02e89fde37f6047d2a7e5399e4f1a222def8ca4ee05
MD5 2841f9bd4d64d516e1fbe2c08afb6b4c
BLAKE2b-256 92480d48b605ae0d7ec5a68e4dfdbe8ba173f489c615c12c4f50c91a8000a3ea

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