{"id":45921,"library":"pytest-pgsql","title":"pytest-pgsql","description":"A pytest plugin providing fixtures and helpers for integration testing with PostgreSQL databases. Version 1.1.2 supports creating temporary test databases, managing database sessions, and rolling back transactions. Release cadence is sporadic.","status":"active","version":"1.1.2","language":"python","source_language":"en","source_url":"https://github.com/CloverHealth/pytest-pgsql","tags":["pytest","postgresql","testing","fixtures","database"],"install":[{"cmd":"pip install pytest-pgsql","lang":"bash","label":"pip"}],"dependencies":[{"reason":"Required as a pytest plugin","package":"pytest","optional":false},{"reason":"Database adapter for PostgreSQL","package":"psycopg2","optional":false},{"reason":"Optional for SQLAlchemy session fixtures","package":"sqlalchemy","optional":true}],"imports":[{"wrong":"from pytest_pgsql import pgsql","symbol":"PostgreSQLTestDB","correct":"from pytest_pgsql import PostgreSQLTestDB"},{"wrong":"from pytest_pgsql import pgsql","symbol":"create_engine_fixture","correct":"from pytest_pgsql import create_engine_fixture"},{"wrong":"from pytest_pgsql import pgsql","symbol":"database","correct":"from pytest_pgsql import database"}],"quickstart":{"code":"def test_example(pgsql):\n    conn = pgsql['conn']\n    cur = conn.cursor()\n    cur.execute(\"SELECT 1\")\n    assert cur.fetchone()[0] == 1","lang":"python","description":"Use the `pgsql` fixture to get a connection to a temporary test database. The fixture creates a fresh database for each test."},"warnings":[{"fix":"Update your requirements to `pytest-pgsql` and change imports from `pytest_postgresql` to `pytest_pgsql`.","message":"Project renamed from `pytest-postgresql` to `pytest-pgsql` in v1.0.0. Old package will be unpinned.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Use `pgsql['conn']` to get the connection, not `pgsql` alone if you expect a connection object.","message":"The `pgsql` fixture returns a dictionary with keys 'conn', 'cur', 'engine', etc. Accessing the fixture directly as a connection object will raise TypeError.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace `pgsql_session` with `pgsql` and manage transactions explicitly or use `pgsql_transaction`.","message":"The `pgsql_session` fixture is deprecated in favor of `pgsql` with `autouse=True` or using `pgsql_transaction` for transactional tests.","severity":"deprecated","affected_versions":">=1.1.0"}],"env_vars":null,"search_vec":"'1.1.2':18 'back':29 'cadenc':32 'creat':20 'databas':16,23,25,39 'fixtur':8,38 'helper':10 'integr':12 'manag':24 'pgsql':3 'plugin':6 'postgresql':15,36 'provid':7 'pytest':2,5,35 'pytest-pgsql':1 'releas':31 'roll':28 'session':26 'sporad':34 'support':19 'temporari':21 'test':13,22,37 'transact':30 'version':17","created_at":"2026-06-07T12:57:23.314440+00:00","updated_at":"2026-06-07T12:57:23.314440+00:00","problems":null,"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/CloverHealth/pytest-pgsql","github":"https://github.com/CloverHealth/pytest-pgsql","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-08-02","install_tag":null}}