Skip to content
faker

faker

faker : Wrapper for the Faker Python library

Overview

ID Extension Package Version Category License Language
3210
faker
faker
0.5.3
LANG
PostgreSQL
Python
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
Requires
plpython3u
See Also
plpython3u
pgtap
dbt2
jsonb_plpython3u
ltree_plpython3u
hstore_plpython3u
random
pg_tle

Requires PL/Python3 and Python Faker; the PIGSTY DEB carries a PG17+ parser compatibility patch.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
MIXED
0.5.3
18
17
16
15
14
faker plpython3u
RPM
PGDG
0.5.3
18
17
16
15
14
postgresql_faker_$v -
DEB
PIGSTY
0.5.3
18
17
16
15
14
postgresql-$v-faker postgresql-plpython3-$v, python3-fake-factory
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
el8.aarch64
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
el9.x86_64
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
el9.aarch64
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
el10.x86_64
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
el10.aarch64
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
PGDG 0.5.3
d12.x86_64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
d12.aarch64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
d13.x86_64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
d13.aarch64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
u22.x86_64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
u22.aarch64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
u24.x86_64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
u24.aarch64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
u26.x86_64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
u26.aarch64
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
PIGSTY 0.5.3
Package Version OS ORG SIZE File URL
postgresql_faker_18 0.5.3 el8.x86_64 pgdg 46.0 KiB postgresql_faker_18-0.5.3-7PGDG.rhel8.x86_64.rpm
postgresql_faker_18 0.5.3 el8.aarch64 pgdg 46.1 KiB postgresql_faker_18-0.5.3-7PGDG.rhel8.aarch64.rpm
postgresql_faker_18 0.5.3 el9.x86_64 pgdg 44.1 KiB postgresql_faker_18-0.5.3-9PGDG.rhel9.8.x86_64.rpm
postgresql_faker_18 0.5.3 el9.x86_64 pgdg 44.0 KiB postgresql_faker_18-0.5.3-7PGDG.rhel9.x86_64.rpm
postgresql_faker_18 0.5.3 el9.aarch64 pgdg 44.1 KiB postgresql_faker_18-0.5.3-9PGDG.rhel9.8.aarch64.rpm
postgresql_faker_18 0.5.3 el9.aarch64 pgdg 43.8 KiB postgresql_faker_18-0.5.3-7PGDG.rhel9.aarch64.rpm
postgresql_faker_18 0.5.3 el10.x86_64 pgdg 44.2 KiB postgresql_faker_18-0.5.3-9PGDG.rhel10.2.x86_64.rpm
postgresql_faker_18 0.5.3 el10.x86_64 pgdg 44.3 KiB postgresql_faker_18-0.5.3-7PGDG.rhel10.x86_64.rpm
postgresql_faker_18 0.5.3 el10.aarch64 pgdg 44.3 KiB postgresql_faker_18-0.5.3-9PGDG.rhel10.2.aarch64.rpm
postgresql_faker_18 0.5.3 el10.aarch64 pgdg 44.5 KiB postgresql_faker_18-0.5.3-7PGDG.rhel10.aarch64.rpm
postgresql-18-faker 0.5.3 d12.x86_64 pigsty 41.9 KiB postgresql-18-faker_0.5.3-1PIGSTY~bookworm_amd64.deb
postgresql-18-faker 0.5.3 d12.aarch64 pigsty 42.0 KiB postgresql-18-faker_0.5.3-1PIGSTY~bookworm_arm64.deb
postgresql-18-faker 0.5.3 d13.x86_64 pigsty 41.9 KiB postgresql-18-faker_0.5.3-1PIGSTY~trixie_amd64.deb
postgresql-18-faker 0.5.3 d13.aarch64 pigsty 42.1 KiB postgresql-18-faker_0.5.3-1PIGSTY~trixie_arm64.deb
postgresql-18-faker 0.5.3 u22.x86_64 pigsty 41.0 KiB postgresql-18-faker_0.5.3-1PIGSTY~jammy_amd64.deb
postgresql-18-faker 0.5.3 u22.aarch64 pigsty 41.1 KiB postgresql-18-faker_0.5.3-1PIGSTY~jammy_arm64.deb
postgresql-18-faker 0.5.3 u24.x86_64 pigsty 41.2 KiB postgresql-18-faker_0.5.3-1PIGSTY~noble_amd64.deb
postgresql-18-faker 0.5.3 u24.aarch64 pigsty 41.2 KiB postgresql-18-faker_0.5.3-1PIGSTY~noble_arm64.deb
postgresql-18-faker 0.5.3 u26.x86_64 pigsty 41.4 KiB postgresql-18-faker_0.5.3-1PIGSTY~resolute_amd64.deb
postgresql-18-faker 0.5.3 u26.aarch64 pigsty 41.5 KiB postgresql-18-faker_0.5.3-1PIGSTY~resolute_arm64.deb

Source

pig build pkg faker;		# build deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install faker;		# install via package name, for the active PG version

pig install faker -v 18;   # install for PG 18
pig install faker -v 17;   # install for PG 17
pig install faker -v 16;   # install for PG 16
pig install faker -v 15;   # install for PG 15
pig install faker -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION faker CASCADE; -- requires plpython3u

Usage

faker: Wrapper for the Faker Python library

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
Last updated on