from psycopg import conninfo
from psycopg_pool import ConnectionPool
from config import DB_HOST, DB_NAME, DB_PASSWORD, DB_PORT, DB_USER
with ConnectionPool(
conninfo=conninfo.make_conninfo(
dbname=DB_NAME,
user=DB_USER,
password=DB_PASSWORD,
host=DB_HOST,
port=DB_PORT,
)
) as pool:
with pool.connection() as conn:
conn.execute("SELECT 1")
with conn.cursor() as cur:
cur.execute("SELECT 1")
< /code>
Dieser Code wird sofort ohne Fehler ausgeführt, aber das Skript läuft eine Weile immer wieder und druckt die folgenden Warnungen: < /p>
couldn't stop thread 'pool-1-worker-0' within 5.0 seconds
hint: you can try to call 'close()' explicitly or to use the pool as context manager
couldn't stop thread 'pool-1-worker-1' within 5.0 seconds
hint: you can try to call 'close()' explicitly or to use the pool as context manager
couldn't stop thread 'pool-1-worker-2' within 5.0 seconds
hint: you can try to call 'close()' explicitly or to use the pool as context manager
couldn't stop thread 'pool-1-scheduler' within 5.0 seconds
hint: you can try to call 'close()' explicitly or to use the pool as context manager
< /code>
und endet schließlich, nachdem Sie diese Warnung zum 4. Mal gezeigt haben. Ich benutze den Pool als Kontextmanager. Ich habe auch versucht, Pool zu addieren. Was mache ich falsch? /> Die Datenbank wird in einem lokalen Docker -Container ausgeführt (postgres :: neuest2025-06-02 16:26:57.780 UTC [86] LOG: statement: BEGIN
2025-06-02 16:26:57.780 UTC [86] LOG: statement: SELECT 1
2025-06-02 16:26:57.781 UTC [86] LOG: statement: COMMIT
2025-06-02 16:26:57.782 UTC [86] LOG: statement: BEGIN
2025-06-02 16:26:57.782 UTC [86] LOG: statement: SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'event_car');
2025-06-02 16:26:57.783 UTC [86] LOG: statement: COMMIT
2025-06-02 16:26:57.783 UTC [86] LOG: statement: BEGIN
2025-06-02 16:26:57.784 UTC [86] LOG: statement: SELECT signal_name, signal_id FROM Signal
2025-06-02 16:26:57.785 UTC [86] LOG: statement: COMMIT
2025-06-02 16:26:57.799 UTC [88] LOG: statement: BEGIN
2025-06-02 16:26:57.799 UTC [88] LOG: statement: SELECT 1
2025-06-02 16:26:57.800 UTC [88] LOG: statement: SELECT 1
2025-06-02 16:26:57.800 UTC [88] LOG: statement: COMMIT
Ich habe dieses Beispiel aus der Psycopg-Dokumentation ausprobiert: < /p> [code]from psycopg import conninfo from psycopg_pool import ConnectionPool
from config import DB_HOST, DB_NAME, DB_PASSWORD, DB_PORT, DB_USER
with ConnectionPool( conninfo=conninfo.make_conninfo( dbname=DB_NAME, user=DB_USER, password=DB_PASSWORD, host=DB_HOST, port=DB_PORT, ) ) as pool: with pool.connection() as conn: conn.execute("SELECT 1")
with conn.cursor() as cur: cur.execute("SELECT 1") < /code> Dieser Code wird sofort ohne Fehler ausgeführt, aber das Skript läuft eine Weile immer wieder und druckt die folgenden Warnungen: < /p> couldn't stop thread 'pool-1-worker-0' within 5.0 seconds hint: you can try to call 'close()' explicitly or to use the pool as context manager couldn't stop thread 'pool-1-worker-1' within 5.0 seconds hint: you can try to call 'close()' explicitly or to use the pool as context manager couldn't stop thread 'pool-1-worker-2' within 5.0 seconds hint: you can try to call 'close()' explicitly or to use the pool as context manager couldn't stop thread 'pool-1-scheduler' within 5.0 seconds hint: you can try to call 'close()' explicitly or to use the pool as context manager < /code> und endet schließlich, nachdem Sie diese Warnung zum 4. Mal gezeigt haben. Ich benutze den Pool als Kontextmanager. Ich habe auch versucht, Pool zu addieren. Was mache ich falsch? /> Die Datenbank wird in einem lokalen Docker -Container ausgeführt (postgres :: neuest2025-06-02 16:26:57.780 UTC [86] LOG: statement: BEGIN 2025-06-02 16:26:57.780 UTC [86] LOG: statement: SELECT 1 2025-06-02 16:26:57.781 UTC [86] LOG: statement: COMMIT 2025-06-02 16:26:57.782 UTC [86] LOG: statement: BEGIN 2025-06-02 16:26:57.782 UTC [86] LOG: statement: SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'event_car'); 2025-06-02 16:26:57.783 UTC [86] LOG: statement: COMMIT 2025-06-02 16:26:57.783 UTC [86] LOG: statement: BEGIN 2025-06-02 16:26:57.784 UTC [86] LOG: statement: SELECT signal_name, signal_id FROM Signal 2025-06-02 16:26:57.785 UTC [86] LOG: statement: COMMIT 2025-06-02 16:26:57.799 UTC [88] LOG: statement: BEGIN 2025-06-02 16:26:57.799 UTC [88] LOG: statement: SELECT 1 2025-06-02 16:26:57.800 UTC [88] LOG: statement: SELECT 1 2025-06-02 16:26:57.800 UTC [88] LOG: statement: COMMIT [/code]
Ich verwende psycopg3, um einen AsyncConnectionPool zu initialisieren. Meine Postgres-Datenbank wird in Azure gehostet. Ich verbinde mich über eine verwaltete Identität. Daher erhalte ich von...
Ich möchte von synchronen DB -Aufrufen zu asynchronen DB -Aufrufen wechseln.
Ich möchte meinen Query Builder nicht ändern. Mein Abfragebauer gibt eine SQL -Abfrage als Zeichenfolge aus (in...
Dies ist die Fehlermeldung:
> C:\Users\alex\PycharmProjects\strongkong\venv\Scripts\python.exe C:\Users\alex\PycharmProjects\strongkong\manage.py runserver 8000
Watching for file changes with...
Ich entwickle eine mobile Anwendung mit Vue -Kondensator. Das modale Fenster in der Anwendung wird mit q-Dialog implementiert. Wenn Sie das modale Fenster mit einem Schlag schließen, scrollt der...