17 lines
558 B
Python
17 lines
558 B
Python
from sqlalchemy import create_engine
|
|
from sqlalchemy.orm import sessionmaker, declarative_base
|
|
|
|
# Configuração do banco de dados
|
|
DATABASE_URL = "sqlite:///./test.db" # SQLite
|
|
# DATABASE_URL = "postgresql://user:password@localhost/dbname" # PostgreSQL
|
|
# DATABASE_URL = "mysql+mysqlconnector://user:password@localhost/dbname" # MySQL
|
|
|
|
# Criando o engine
|
|
engine = create_engine(DATABASE_URL, echo=True)
|
|
|
|
# Criando uma sessão
|
|
SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False)
|
|
|
|
# Base para os modelos ORM
|
|
Base = declarative_base()
|