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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file filgood-0.1.2.tar.gz.
File metadata
- Download URL: filgood-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17d9509f4603fc5a6dd5d32bf1a9084cc569bbdf51c5e5b48c2385dd5c71bac4
|
|
| MD5 |
d4c16a97cf05574a3ba616878dff436f
|
|
| BLAKE2b-256 |
bdf6165211babf94ba206e6ec0200db8149c1e423fee37531bbf30ebd9b80d2b
|
File details
Details for the file filgood-0.1.2-py3-none-any.whl.
File metadata
- Download URL: filgood-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f919539c41de384c2db394f6a364b02b15bf0806dfb78c384bf461b9955fcb5
|
|
| MD5 |
80f28e4285ab9c743dd47043e6a257e5
|
|
| BLAKE2b-256 |
6a65d35f9d25103f43d1f9a89181dfe7241293f3a0d1c0e1af159463a943822e
|