Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from sqlalchemy.ext.declarative import declarative_base
- from sqlalchemy import Column, String, Integer, ForeignKey
- Base = declarative_base()
- class Pessoa(Base):
- __tablename__ = 'pessoas'
- id = Column(Integer, primary_key=True)
- nome = Column(String(100), nullable=False)
- def __init__(self, id, nome):
- self.id = id
- self.nome = nome
- def __str__(self):
- return self.nome
- if __name__ == '__main__':
- p = Pessoa(1111, nome='Marcos Castro')
- print(p) # imprime o nome da pessoa
- print(p.id) # imprime o ID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement