Python API for pg0 - embedded PostgreSQL
Project description
pg0 - Embedded PostgreSQL for Python
Zero-config PostgreSQL with pgvector support. Just pip install and go.
Installation
pip install pg0-embedded
Quick Start
from pg0 import Pg0
# Start PostgreSQL (auto-installs on first run)
pg = Pg0()
pg.start()
print(pg.uri) # postgresql://postgres:postgres@localhost:5432/postgres
pg.stop()
Context Manager
from pg0 import Pg0
with Pg0() as pg:
print(pg.uri)
pg.execute("CREATE EXTENSION IF NOT EXISTS vector")
pg.execute("SELECT version()")
# Automatically stopped
Custom Configuration
from pg0 import Pg0
pg = Pg0(
port=5433,
username="myuser",
password="mypass",
database="mydb",
config={
"shared_buffers": "512MB",
"maintenance_work_mem": "1GB",
}
)
with pg:
print(pg.uri)
Multiple Instances
from pg0 import Pg0, list_instances
# Run multiple PostgreSQL instances
app = Pg0(name="app", port=5432)
test = Pg0(name="test", port=5433)
app.start()
test.start()
for instance in list_instances():
print(f"{instance.name}: {instance.uri}")
app.stop()
test.stop()
API Reference
Pg0 Class
pg = Pg0(
name="default", # Instance name
port=5432, # Port
username="postgres", # Username
password="postgres", # Password
database="postgres", # Database
data_dir=None, # Custom data directory
config={}, # PostgreSQL config options
)
pg.start() # Start PostgreSQL -> InstanceInfo
pg.stop() # Stop PostgreSQL
pg.info() # Get instance info -> InstanceInfo
pg.uri # Connection URI (property)
pg.running # Is running (property)
pg.execute(sql) # Execute SQL -> str
pg.psql(*args) # Run psql command
Module Functions
import pg0
pg0.start(port=5432, ...) # Start instance -> InstanceInfo
pg0.stop(name="default") # Stop instance
pg0.info(name="default") # Get info -> InstanceInfo
pg0.list_instances() # List all -> [InstanceInfo]
pg0.install(version=None) # Install pg0 binary
InstanceInfo
info.name # Instance name
info.running # Is running
info.pid # Process ID
info.port # Port
info.uri # Connection URI
info.username # Username
info.database # Database
info.data_dir # Data directory
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 pg0_embedded-0.1.1.tar.gz.
File metadata
- Download URL: pg0_embedded-0.1.1.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fb39f5a7e45257e95379cc5fcff226d7c7f17a081806d9eead00fe903ccca789
|
|
| MD5 |
9ec76ff3a0923ea30d54d9224e059fab
|
|
| BLAKE2b-256 |
b14ccae8662ba15f6607e030c57d1195347159721e503991e3c55d7f1a8beab6
|
Provenance
The following attestation bundles were made for pg0_embedded-0.1.1.tar.gz:
Publisher:
release-python.yml on vectorize-io/pg0
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pg0_embedded-0.1.1.tar.gz -
Subject digest:
fb39f5a7e45257e95379cc5fcff226d7c7f17a081806d9eead00fe903ccca789 - Sigstore transparency entry: 737324614
- Sigstore integration time:
-
Permalink:
vectorize-io/pg0@20efe81c40b52ac460b5e70e8b0753911a656159 -
Branch / Tag:
refs/tags/py-0.1.1 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@20efe81c40b52ac460b5e70e8b0753911a656159 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pg0_embedded-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pg0_embedded-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
643500836abf4d09a4f20db31d3c80ad16dc273ade439dafc86f1735a384d9ba
|
|
| MD5 |
27bb714baee1c008bd6f314012e3294b
|
|
| BLAKE2b-256 |
6d286e8de2e0d55b09d17bc4547e3d57d5d5856c35785001dbe81cd372f062e6
|
Provenance
The following attestation bundles were made for pg0_embedded-0.1.1-py3-none-any.whl:
Publisher:
release-python.yml on vectorize-io/pg0
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pg0_embedded-0.1.1-py3-none-any.whl -
Subject digest:
643500836abf4d09a4f20db31d3c80ad16dc273ade439dafc86f1735a384d9ba - Sigstore transparency entry: 737324615
- Sigstore integration time:
-
Permalink:
vectorize-io/pg0@20efe81c40b52ac460b5e70e8b0753911a656159 -
Branch / Tag:
refs/tags/py-0.1.1 - Owner: https://github.com/vectorize-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@20efe81c40b52ac460b5e70e8b0753911a656159 -
Trigger Event:
push
-
Statement type: