{"id":45762,"library":"pg0-embedded","title":"pg0-embedded","description":"Python API for pg0 - embedded PostgreSQL. Version 0.14.2, updated semi-regularly. Provides a PostgreSQL server that starts and stops with your Python process, ideal for testing and ephemeral databases.","status":"active","version":"0.14.2","language":"python","source_language":"en","source_url":"https://github.com/vectorize-io/pg0","tags":["embedded-postgresql","testing","database"],"install":[{"cmd":"pip install pg0-embedded","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The package is a module, not a class. Use import pg0 and access functions like pg0.start()","wrong":"from pg0 import pg0","symbol":"pg0","correct":"import pg0"}],"quickstart":{"code":"import pg0\nimport os\n\npg0_options = {\n    'host': os.environ.get('PGHOST', 'localhost'),\n    'port': int(os.environ.get('PGPORT', 5432)),\n    'database': os.environ.get('PGDATABASE', 'test'),\n    'user': os.environ.get('PGUSER', 'postgres'),\n    'password': os.environ.get('PGPASSWORD', 'postgres')\n}\n\npg0.start()\n# Now you can connect and run SQL\npg0.stop()","lang":"python","description":"Start an embedded PostgreSQL server, connect with psycopg2 or asyncpg, then stop."},"warnings":[{"fix":"Update to using pg0.start() and pg0.stop() directly. Remove old 'with pg0: ...' patterns.","message":"pg0.start() and pg0.stop() replaced the older context manager style. The library now starts immediately without context.","severity":"breaking","affected_versions":"<0.12.0"},{"fix":"Call pg0.initialize() once at the beginning of your script, especially on Windows.","message":"pg0.initialize() must be called before start() on Windows or in certain environments. Failure to call initialize() leads to obscure errors.","severity":"gotcha","affected_versions":">=0.10.0"},{"fix":"Set a persistent data directory using pg0.set_data_directory(path) before calling pg0.start() if you need to preserve data between runs.","message":"The embedded PostgreSQL server uses a temporary data directory by default. Data is lost after pg0.stop() unless you set a persistent directory via pg0.set_data_directory('/path/to/data').","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'0.14.2':11 'api':5 'databas':33,38 'embed':3,8,35 'embedded-postgresql':34 'ephemer':32 'ideal':28 'pg0':2,7 'pg0-embedded':1 'postgresql':9,18,36 'process':27 'provid':16 'python':4,26 'regular':15 'semi':14 'semi-regular':13 'server':19 'start':21 'stop':23 'test':30,37 'updat':12 'version':10","created_at":"2026-06-07T12:56:35.829354+00:00","updated_at":"2026-06-07T12:56:35.829354+00:00","problems":[{"fix":"Install using 'pip install pg0-embedded'. The import is 'import pg0'.","cause":"Package not installed or installed under a different name (e.g., 'pg0-embedded').","error":"ModuleNotFoundError: No module named 'pg0'"},{"fix":"Add 'pg0.initialize()' before calling 'pg0.start()'.","cause":"On some platforms (especially Windows), pg0 requires explicit initialization before start.","error":"RuntimeError: pg0 is not initialized. Did you forget to call pg0.initialize()?"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/vectorize-io/pg0","github":"https://github.com/vectorize-io/pg0","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-29","last_verified":"2026-06-29","next_check":"2026-07-29","install_tag":null}}