items-models-import-error
This commit is contained in:
parent
938f950646
commit
7c35097c88
5 changed files with 94 additions and 32 deletions
12
config.py
12
config.py
|
|
@ -1,6 +1,5 @@
|
|||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlalchemy.orm import sessionmaker, DeclarativeBase
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from passlib.context import CryptContext
|
||||
|
|
@ -21,11 +20,16 @@ DATABASE_URL = os.getenv("DATABASE_URL")
|
|||
engine = create_engine(DATABASE_URL, echo=False)
|
||||
# Session factory oluştur
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
Base = declarative_base() #sqlalchemy için bu sınıfı kullanıyoruz 'class DBUser(Base)' şeklinde tanımlıyoruz
|
||||
#Base = declarative_base() #sqlalchemy için bu sınıfı kullanıyoruz 'class DBUser(Base)' şeklinde tanımlıyoruz
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
pass #yeni sqlalchemy sürümünde bu sınıfı kullanıyoruz
|
||||
|
||||
|
||||
#models te içe aktarmayı unutma
|
||||
|
||||
def init_db():
|
||||
Base.metadata.drop_all(engine) # Veritabanını her başlangıcta siler burayada dikkat !!!!!!!!
|
||||
#Base.metadata.drop_all(engine) # Veritabanını her başlangıcta siler burayada dikkat !!!!!!!!
|
||||
Base.metadata.create_all(bind=engine)
|
||||
|
||||
# Session dependency (FastAPI için)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue