mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
fix: remove mongo
This commit is contained in:
parent
573b9a43fc
commit
ac70cb534d
4 changed files with 13 additions and 22 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import logging
|
||||
from config.config import get_learnhouse_config
|
||||
from fastapi import FastAPI
|
||||
import motor.motor_asyncio
|
||||
from sqlmodel import SQLModel, Session, create_engine
|
||||
|
||||
|
||||
learnhouse_config = get_learnhouse_config()
|
||||
engine = create_engine(
|
||||
"postgresql://learnhouse:learnhouse@db:5432/learnhouse", echo=False
|
||||
learnhouse_config.database_config.sql_connection_string, echo=False
|
||||
)
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
|
|
@ -16,12 +16,6 @@ async def connect_to_db(app: FastAPI):
|
|||
|
||||
SQLModel.metadata.create_all(engine)
|
||||
|
||||
# mongodb
|
||||
app.mongodb_client = motor.motor_asyncio.AsyncIOMotorClient( # type: ignore
|
||||
app.learnhouse_config.database_config.mongodb_connection_string # type: ignore
|
||||
) # type: ignore
|
||||
app.db = app.mongodb_client["learnhouse"] # type: ignore
|
||||
|
||||
|
||||
def get_db_session():
|
||||
with Session(engine) as session:
|
||||
|
|
@ -29,6 +23,5 @@ def get_db_session():
|
|||
|
||||
|
||||
async def close_database(app: FastAPI):
|
||||
app.mongodb_client.close() # type: ignore
|
||||
logging.info("LearnHouse has been shut down.")
|
||||
return app
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
from enum import Enum
|
||||
from typing import Optional
|
||||
from sqlalchemy import JSON, Column
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlalchemy import BigInteger, Column, ForeignKey
|
||||
from sqlmodel import Field, SQLModel
|
||||
from sqlalchemy import BigInteger, ForeignKey, JSON, Column
|
||||
|
||||
|
||||
class TrailStepTypeEnum(str, Enum):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue