pip install sqlalchemy
python
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
python
Base = declarative_base()
python
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String(50))
email = Column(String(50))
python
python
Base.metadata.create_all(engine)
python
Session = sessionmaker(bind=engine)
session = Session()
python
new_user = User(name='John', email='john@example.com')
session.add(new_user)
session.commit()