This is the models.py
used to create a table:
from sqlalchemy import Column, Integer, String,Boolean,BigInteger,Date
from sqlalchemy.orm import relationship
from database import database
Base=database.Base
class country_table(Base):
__tablename__='country'
CountryId = Column(Integer(), primary_key=True, index=True)
CountryName = Column(String(25))
IsActive = Column(Boolean, default=False)
CreatedDate = Column(Date())
CreatedBy = Column(BigInteger())
UpdatedDate = Column(Date())
UpdatedBy = Column(BigInteger())
Is_delete = Column(Boolean, default=False)
This is the database.py
that is creating an engine and processing a table:
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
SQLALCHEMY_DATABASE_URL = 'mysql+mysqlconnector://root:1234@localhost:3306/property_valuation'
engine = create_engine(SQLALCHEMY_DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
def get_db():
db = SessionLocal()
try:
yield db
finally:
db.close()
I want to connect with a stored procedure and call the procedure in FastAPI. Where do I want to call and how can call?