postgres healthcheck works
This commit is contained in:
parent
91c79357f8
commit
c38ce5cfe6
9 changed files with 203 additions and 8 deletions
27
anaxi/postgres_tools.py
Normal file
27
anaxi/postgres_tools.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import psycopg2
|
||||
from psycopg2.sql import SQL
|
||||
|
||||
from anaxi.config import PostgresDatabaseConfig
|
||||
|
||||
|
||||
def create_postgres_connection_from_config(config: PostgresDatabaseConfig):
|
||||
return psycopg2.connect(
|
||||
dbname=config.dbname,
|
||||
user=config.user,
|
||||
password=config.password,
|
||||
host=config.host,
|
||||
port=config.port,
|
||||
)
|
||||
|
||||
|
||||
def simply_query(config: PostgresDatabaseConfig, query: SQL):
|
||||
with psycopg2.connect(
|
||||
dbname=config.dbname,
|
||||
user=config.user,
|
||||
password=config.password,
|
||||
host=config.host,
|
||||
port=config.port,
|
||||
) as db_connection:
|
||||
cursor = db_connection.cursor()
|
||||
cursor.execute(query)
|
||||
return cursor.fetchall()
|
||||
Loading…
Add table
Add a link
Reference in a new issue