faker
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
faker | 0.5.3 | LANG | PostgreSQL | Python |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3210 | faker | No | Yes | No | Yes | No | No | - |
| Related | plpython3u pgtap dbt2 jsonb_plpython3u ltree_plpython3u hstore_plpython3u random pg_tle |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 0.5.3 | 1817161514 | faker | - |
| RPM | PGDG | 0.5.3 | 1817161514 | postgresql_faker_$v | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 0.5.3 el8.x86_64.pg18 : postgresql_faker_18 postgresql_faker_18-0.5.3-7PGDG.rhel8.x86_64.rpm
| PGDG 0.5.3 el8.x86_64.pg17 : postgresql_faker_17 postgresql_faker_17-0.5.3-6PGDG.rhel8.x86_64.rpm
| PGDG 0.5.3 el8.x86_64.pg16 : postgresql_faker_16 postgresql_faker_16-0.5.3-3PGDG.rhel8.x86_64.rpm
| PGDG 0.5.3 el8.x86_64.pg15 : postgresql_faker_15 postgresql_faker_15-0.5.3-1.rhel8.x86_64.rpm
| PGDG 0.5.3 el8.x86_64.pg14 : postgresql_faker_14 postgresql_faker_14-0.5.3-1.rhel8.x86_64.rpm
postgresql_faker_14-0.4.0-1.rhel8.noarch.rpm
|
| el8.aarch64 | PGDG 0.5.3 el8.aarch64.pg18 : postgresql_faker_18 postgresql_faker_18-0.5.3-7PGDG.rhel8.aarch64.rpm
| PGDG 0.5.3 el8.aarch64.pg17 : postgresql_faker_17 postgresql_faker_17-0.5.3-6PGDG.rhel8.aarch64.rpm
| PGDG 0.5.3 el8.aarch64.pg16 : postgresql_faker_16 postgresql_faker_16-0.5.3-3PGDG.rhel8.aarch64.rpm
| PGDG 0.5.3 el8.aarch64.pg15 : postgresql_faker_15 postgresql_faker_15-0.5.3-1.rhel8.aarch64.rpm
| PGDG 0.5.3 el8.aarch64.pg14 : postgresql_faker_14 postgresql_faker_14-0.5.3-1.rhel8.aarch64.rpm
|
| el9.x86_64 | PGDG 0.5.3 el9.x86_64.pg18 : postgresql_faker_18 postgresql_faker_18-0.5.3-7PGDG.rhel9.x86_64.rpm
| PGDG 0.5.3 el9.x86_64.pg17 : postgresql_faker_17 postgresql_faker_17-0.5.3-6PGDG.rhel9.x86_64.rpm
| PGDG 0.5.3 el9.x86_64.pg16 : postgresql_faker_16 postgresql_faker_16-0.5.3-3PGDG.rhel9.x86_64.rpm
| PGDG 0.5.3 el9.x86_64.pg15 : postgresql_faker_15 postgresql_faker_15-0.5.3-1.rhel9.x86_64.rpm
| PGDG 0.5.3 el9.x86_64.pg14 : postgresql_faker_14 postgresql_faker_14-0.5.3-1.rhel9.x86_64.rpm
postgresql_faker_14-0.5.3-1.rhel9.noarch.rpm
|
| el9.aarch64 | PGDG 0.5.3 el9.aarch64.pg18 : postgresql_faker_18 postgresql_faker_18-0.5.3-7PGDG.rhel9.aarch64.rpm
| PGDG 0.5.3 el9.aarch64.pg17 : postgresql_faker_17 postgresql_faker_17-0.5.3-6PGDG.rhel9.aarch64.rpm
| PGDG 0.5.3 el9.aarch64.pg16 : postgresql_faker_16 postgresql_faker_16-0.5.3-3PGDG.rhel9.aarch64.rpm
| PGDG 0.5.3 el9.aarch64.pg15 : postgresql_faker_15 postgresql_faker_15-0.5.3-1.rhel9.aarch64.rpm
| PGDG 0.5.3 el9.aarch64.pg14 : postgresql_faker_14 postgresql_faker_14-0.5.3-1.rhel9.aarch64.rpm
|
| el10.x86_64 | PGDG 0.5.3 el10.x86_64.pg18 : postgresql_faker_18 postgresql_faker_18-0.5.3-7PGDG.rhel10.x86_64.rpm
| PGDG 0.5.3 el10.x86_64.pg17 : postgresql_faker_17 postgresql_faker_17-0.5.3-7PGDG.rhel10.x86_64.rpm
| PGDG 0.5.3 el10.x86_64.pg16 : postgresql_faker_16 postgresql_faker_16-0.5.3-7PGDG.rhel10.x86_64.rpm
| PGDG 0.5.3 el10.x86_64.pg15 : postgresql_faker_15 postgresql_faker_15-0.5.3-7PGDG.rhel10.x86_64.rpm
| PGDG 0.5.3 el10.x86_64.pg14 : postgresql_faker_14 postgresql_faker_14-0.5.3-7PGDG.rhel10.x86_64.rpm
|
| el10.aarch64 | PGDG 0.5.3 el10.aarch64.pg18 : postgresql_faker_18 postgresql_faker_18-0.5.3-7PGDG.rhel10.aarch64.rpm
| PGDG 0.5.3 el10.aarch64.pg17 : postgresql_faker_17 postgresql_faker_17-0.5.3-7PGDG.rhel10.aarch64.rpm
| PGDG 0.5.3 el10.aarch64.pg16 : postgresql_faker_16 postgresql_faker_16-0.5.3-7PGDG.rhel10.aarch64.rpm
| PGDG 0.5.3 el10.aarch64.pg15 : postgresql_faker_15 postgresql_faker_15-0.5.3-7PGDG.rhel10.aarch64.rpm
| PGDG 0.5.3 el10.aarch64.pg14 : postgresql_faker_14 postgresql_faker_14-0.5.3-7PGDG.rhel10.aarch64.rpm
|
| d12.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d12.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d13.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| d13.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u22.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u22.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u24.x86_64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
| u24.aarch64 | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS | PGDG MISS |
Install
You can install faker directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install faker; # Install for current active PG version
pig ext install -y faker -v 18 # PG 18
pig ext install -y faker -v 17 # PG 17
pig ext install -y faker -v 16 # PG 16
pig ext install -y faker -v 15 # PG 15
pig ext install -y faker -v 14 # PG 14
dnf install -y postgresql_faker_18 # PG 18
dnf install -y postgresql_faker_17 # PG 17
dnf install -y postgresql_faker_16 # PG 16
dnf install -y postgresql_faker_15 # PG 15
dnf install -y postgresql_faker_14 # PG 14
Create Extension:
CREATE EXTENSION faker;
Usage
faker is a PostgreSQL extension that wraps Python’s Faker library, providing functions to generate realistic fake data directly in SQL queries. It requires plpython3u.
CREATE EXTENSION faker;
Generate Fake Data
SELECT faker.name(); -- 'John Smith'
SELECT faker.first_name(); -- 'Jane'
SELECT faker.last_name(); -- 'Doe'
SELECT faker.email(); -- '[email protected]'
SELECT faker.address(); -- '123 Main St, Anytown, US 12345'
SELECT faker.company(); -- 'Smith LLC'
SELECT faker.phone_number(); -- '(555) 123-4567'
SELECT faker.text(); -- random paragraph of text
SELECT faker.city(); -- 'Portland'
SELECT faker.country(); -- 'United States'
Note: faker.date() and faker.time() are not available because date and time are reserved PostgreSQL keywords. Use faker.date_between() or faker.date_this_century() instead.
Populate Tables with Fake Data
INSERT INTO users (name, email, address, created_at)
SELECT
faker.name(),
faker.email(),
faker.address(),
faker.date_this_century()::timestamp
FROM generate_series(1, 1000);
Localized Fake Data
Locale is set per session, not per function call:
SELECT faker.faker('de_DE'); -- set locale for this session
SELECT faker.name(); -- returns a German name
SELECT faker.address(); -- returns a German address
Unique Values
Use the unique_ prefix to guarantee unique values within a session:
SELECT faker.unique_name();
SELECT faker.unique_email();
Discover All Functions
SELECT faker._functions(); -- list all 500+ available functions
All faker functions return text. Cast explicitly for other types.
Common Faker Providers
| Function | Description |
|---|---|
faker.name() | Full name |
faker.first_name() | First name |
faker.last_name() | Last name |
faker.email() | Email address |
faker.company_email() | Company email |
faker.phone_number() | Phone number |
faker.address() | Full address |
faker.city() | City name |
faker.country() | Country name |
faker.company() | Company name |
faker.text() | Random text |
faker.date_this_century() | Random date |
faker.ssn() | Social security number |
faker.ean() | EAN barcode |
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.