Iniciando com SQLAlchemy
Instação e primeiros passos com SQL Alchemy
Instalar o pacote do SQLAlchemy pelo repositório PiPy
pip install sqlalchemy
engine = create_engine('sqlite:///mydb.db', poolclass=SingletonThreadPool)
Base.metadata.create_all(engine)
Session = sessionmaker(bind=engine)
session = Session()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
user = Column(String(50), nullable=False)
password = Column(String(50), nullable=False)
def __repr__(self):
return "<User (user='%d')>" % (self.user)