{"library":"psycogreen","title":"psycogreen","description":"Psycogreen is a library that enables the `psycopg2` PostgreSQL adapter to work with coroutine-based libraries like Gevent and Eventlet. It provides \"wait callbacks\" that integrate `psycopg2`'s asynchronous calls with the event loops of these coroutine libraries, allowing `psycopg2` to operate in a non-blocking manner within a green-thread environment while presenting a synchronous interface to the application. The library is currently at version 1.0.2, with no new releases since 2020, suggesting it is in maintenance mode.","language":"python","status":"maintenance","last_verified":"Fri May 15","install":{"commands":["pip install psycogreen"],"cli":null},"imports":["from psycogreen.gevent import patch_psycopg","from psycogreen.eventlet import patch_psycopg"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nimport gevent.monkey\nimport psycopg2\n\n# Apply gevent monkey patching for standard library modules\ngevent.monkey.patch_all()\n\n# Apply psycogreen patching for psycopg2\nfrom psycogreen.gevent import patch_psycopg\npatch_psycopg()\n\n# Now psycopg2 operations will yield to gevent\ntry:\n    # Use os.environ.get for database connection details for runnable example\n    conn = psycopg2.connect(\n        host=os.environ.get('PGHOST', 'localhost'),\n        database=os.environ.get('PGDATABASE', 'testdb'),\n        user=os.environ.get('PGUSER', 'postgres'),\n        password=os.environ.get('PGPASSWORD', 'password'),\n        port=os.environ.get('PGPORT', '5432')\n    )\n    cur = conn.cursor()\n    cur.execute(\"SELECT 1 + 1 AS result;\")\n    result = cur.fetchone()[0]\n    print(f\"PostgreSQL query result (green): {result}\")\n    cur.close()\n    conn.close()\nexcept psycopg2.OperationalError as e:\n    print(f\"Could not connect to PostgreSQL. Please ensure a PostgreSQL instance is running and accessible. Error: {e}\")\nexcept ImportError as e:\n    print(f\"Required modules (gevent, psycogreen, psycopg2) not installed. Error: {e}\")","lang":"python","description":"This quickstart demonstrates patching `psycopg2` with `psycogreen` for use with Gevent. It's crucial to call `gevent.monkey.patch_all()` and `psycogreen.gevent.patch_psycopg()` early in your application's lifecycle, typically before any `psycopg2` imports or connections are made. The example connects to a PostgreSQL database using environment variables for credentials and executes a simple query.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"1.0.2","pypi_latest":"1.0.2","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3.2,"avg_import_s":null,"wheel_type":"sdist"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.8M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":3.4,"import_time_s":null,"mem_mb":null,"disk_size":"18M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":3.2,"import_time_s":null,"mem_mb":null,"disk_size":"20M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.5M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":3,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":2.6,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"psycogreen","exit_code":0,"wheel_type":"sdist","failure_reason":null,"import_side_effects":"broken","install_time_s":3.8,"import_time_s":null,"mem_mb":null,"disk_size":"18M"}]}}