Fake Data Generator · Tutorial
How to fill a test database with fake orders
7 min readbeginnerUpdated
An empty development database makes it hard to test reports, pagination and search. You will define an orders table, generate 20 rows of believable data as SQL, and load them, all without copying any real customer data.
What you need
- The Fake Data Generator
- A development database, such as PostgreSQL, MySQL or SQLite
Steps
Describe the columns
Add one field per column:
order_idas Row number,customeras Full name,productas Product name,quantityas Whole number with range1-5,priceas Price with5-250,paidas True / false, andordered_atas Date and time with2026-01-01 to 2026-10-31.Choose SQL output
Set Format to SQL INSERT, pick your Database and type
ordersas the table name. The output starts with a CREATE TABLE statement whose types match the data.CREATE TABLE "orders" ( "order_id" integer NOT NULL, "customer" text NOT NULL, ... );Set the number of rows
Start with 20 rows to check the result, then raise it to a few thousand to test pagination and slow queries.
Load it into the database
Download the file and run it with your database client, for example
psql -d dev -f test-data.sqlorsqlite3 dev.db < test-data.sql.Keep the seed
Write the seed into your project’s README. Anyone on the team can generate exactly the same rows, so bug reports like “order 17 shows the wrong total” mean the same order for everyone.
Try it yourself
Opens the Fake Data Generator with this tutorial's sample loaded.
Common mistakes
- Running it against a database that already has the table
- The CREATE TABLE statement fails if
ordersalready exists. Drop the test table first, or delete the CREATE TABLE part and keep only the INSERT statements. - Expecting related rows to match
- Each table is generated on its own, so customer names in orders won’t match a separate customers table. For foreign keys, use Row number fields and a Whole number range that matches the other table’s IDs.
Next steps
Go back to the Fake Data Generator, or keep going with one of these:
FAQ
Can I generate data for several tables?
Yes. Generate each table separately with its own fields and table name, then run the files in order.