Updated
This commit is contained in:
7673
schema/mssql_schema_export.csv
Normal file
7673
schema/mssql_schema_export.csv
Normal file
File diff suppressed because it is too large
Load Diff
1438
schema/routeriai.sql
Normal file
1438
schema/routeriai.sql
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,15 +0,0 @@
|
|||||||
import pytest
|
|
||||||
|
|
||||||
from uv_app.example_util import addition
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
("a", "b", "expected"),
|
|
||||||
[
|
|
||||||
(2, 3, 5),
|
|
||||||
(1.5, 2.5, 4.0),
|
|
||||||
(-1, 1, 0),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
def test_addition_returns_sum(a: float, b: float, expected: float) -> None:
|
|
||||||
assert addition(a, b) == expected
|
|
||||||
31
uv_app/core/pgsql.py
Normal file
31
uv_app/core/pgsql.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import os
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
import psycopg2
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
# Force reload environment variables from .env, ignoring system vars.
|
||||||
|
load_dotenv(override=True)
|
||||||
|
|
||||||
|
DB_HOST = os.getenv("DB_HOST")
|
||||||
|
DB_PORT = os.getenv("DB_PORT")
|
||||||
|
DB_NAME = os.getenv("DB_NAME")
|
||||||
|
DB_USER = os.getenv("DB_USER")
|
||||||
|
DB_PASSWORD = os.getenv("DB_PASSWORD")
|
||||||
|
|
||||||
|
|
||||||
|
def connect_to_pgsql() -> Optional[psycopg2.extensions.connection]:
|
||||||
|
"""Establish a connection to the PostgreSQL database."""
|
||||||
|
try:
|
||||||
|
return psycopg2.connect(
|
||||||
|
host=DB_HOST,
|
||||||
|
port=DB_PORT,
|
||||||
|
database=DB_NAME,
|
||||||
|
user=DB_USER,
|
||||||
|
password=DB_PASSWORD,
|
||||||
|
# Set the client encoding to UTF-8.
|
||||||
|
options="-c client_encoding=utf8",
|
||||||
|
)
|
||||||
|
except psycopg2.Error as exc:
|
||||||
|
print(f"Error connecting to PostgreSQL database: {exc}")
|
||||||
|
return None
|
||||||
Reference in New Issue
Block a user