统一连接到新的数据库到openproject api 下
This commit is contained in:
@@ -18,7 +18,13 @@ class Database:
|
||||
"""Initialize the connection pool."""
|
||||
# Use provided db_name, or the one from constructor, or default from config
|
||||
target_db_name = db_name or self.db_name
|
||||
conn_string = timescaledb_info.get_pgconn_string(db_name=target_db_name)
|
||||
|
||||
# Get connection string, handling default case where target_db_name might be None
|
||||
if target_db_name:
|
||||
conn_string = timescaledb_info.get_pgconn_string(db_name=target_db_name)
|
||||
else:
|
||||
conn_string = timescaledb_info.get_pgconn_string()
|
||||
|
||||
try:
|
||||
self.pool = psycopg_pool.AsyncConnectionPool(
|
||||
conninfo=conn_string,
|
||||
@@ -47,7 +53,9 @@ class Database:
|
||||
def get_pgconn_string(self, db_name=None):
|
||||
"""Get the TimescaleDB connection string."""
|
||||
target_db_name = db_name or self.db_name
|
||||
return timescaledb_info.get_pgconn_string(db_name=target_db_name)
|
||||
if target_db_name:
|
||||
return timescaledb_info.get_pgconn_string(db_name=target_db_name)
|
||||
return timescaledb_info.get_pgconn_string()
|
||||
|
||||
@asynccontextmanager
|
||||
async def get_connection(self) -> AsyncGenerator:
|
||||
|
||||
Reference in New Issue
Block a user