Spaces:
Sleeping
Sleeping
Commit ·
c122fff
1
Parent(s): 502a8cc
Refactor database connection: move connection logic to db.py and update imports in app.py and schema.py
Browse files- app.py +1 -1
- sql.py → db.py +1 -1
- schema.py +1 -1
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
|
| 2 |
from fastapi import FastAPI, HTTPException
|
| 3 |
-
from
|
| 4 |
from schema import rca_results, RCAResult
|
| 5 |
import logging
|
| 6 |
|
|
|
|
| 1 |
|
| 2 |
from fastapi import FastAPI, HTTPException
|
| 3 |
+
from db import connect_to_database, disconnect_from_database, database
|
| 4 |
from schema import rca_results, RCAResult
|
| 5 |
import logging
|
| 6 |
|
sql.py → db.py
RENAMED
|
@@ -57,4 +57,4 @@ async def disconnect_from_database():
|
|
| 57 |
logger.info("Successfully disconnected from the database.")
|
| 58 |
except Exception as e:
|
| 59 |
logger.error("Error disconnecting from the database: %s", e)
|
| 60 |
-
raise
|
|
|
|
| 57 |
logger.info("Successfully disconnected from the database.")
|
| 58 |
except Exception as e:
|
| 59 |
logger.error("Error disconnecting from the database: %s", e)
|
| 60 |
+
raise
|
schema.py
CHANGED
|
@@ -10,7 +10,7 @@ import sqlalchemy
|
|
| 10 |
from sqlalchemy import (
|
| 11 |
Table, Column, String, Integer, DateTime, ForeignKey, Text, func, JSON
|
| 12 |
)
|
| 13 |
-
from
|
| 14 |
|
| 15 |
|
| 16 |
rca_results = Table(
|
|
|
|
| 10 |
from sqlalchemy import (
|
| 11 |
Table, Column, String, Integer, DateTime, ForeignKey, Text, func, JSON
|
| 12 |
)
|
| 13 |
+
from db import metadata
|
| 14 |
|
| 15 |
|
| 16 |
rca_results = Table(
|