Advertisement
Guest User

PythonPasteThp

a guest
Jun 28th, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. import os
  2. import sys
  3. from sqlalchemy import Column, ForeignKey, Integer, String
  4. from sqlalchemy.ext.declarative import declarative_base
  5. from sqlalchemy.orm import relationship
  6. from sqlalchemy import create_engine
  7. from sqlalchemy import schema, types
  8. from sqlalchemy.sql import select
  9. from sqlalchemy.sql import and_, or_, not_
  10. from sqlalchemy import update
  11. from sqlalchemy import delete
  12. from passlib.hash import pbkdf2_sha256
  13. from sqlalchemy import *
  14.  
  15. DK = pbkdf2_sha256.encrypt("key", round=100000, salt_size=16)
  16.  
  17. Base = declarative_base()
  18.  
  19. class User(Base):
  20. __tablename__ = 'user'
  21. # Here we define columns for the table user
  22. # Notice that each column is also a normal Python instance attribute.
  23. id = Column(Integer, primary_key=True)
  24. username = Column(types.Unicode(255), nullable=False)
  25. password = Column(types.Text(), default=DK, nullable=False)
  26.  
  27.  
  28.  
  29. # Create an engine that stores data in the local directory's
  30. # sqlalchemy_example.db file.
  31. engine = create_engine('sqlite:///sqlalchemy_login.db')
  32.  
  33. # Create all tables in the engine. This is equivalent to "Create Table"
  34. # statements in raw SQL.
  35. Base.metadata.create_all(engine)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement