Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. from sqlalchemy.ext.declarative import declarative_base
  2. from sqlalchemy import Column, String, Integer, ForeignKey
  3.  
  4.  
  5. Base = declarative_base()
  6.  
  7. class Pessoa(Base):
  8. __tablename__ = 'pessoas'
  9. id = Column(Integer, primary_key=True)
  10. nome = Column(String(100), nullable=False)
  11.  
  12. def __init__(self, id, nome):
  13. self.id = id
  14. self.nome = nome
  15.  
  16. def __str__(self):
  17. return self.nome
  18.  
  19. if __name__ == '__main__':
  20. p = Pessoa(1111, nome='Marcos Castro')
  21. print(p) # imprime o nome da pessoa
  22. print(p.id) # imprime o ID
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement