Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- from sqlalchemy import Column, ForeignKey, Integer, String
- from sqlalchemy.ext.declarative import declarative_base
- from sqlalchemy.orm import relationship
- from sqlalchemy import create_engine
- from sqlalchemy import schema, types
- from sqlalchemy.sql import select
- from sqlalchemy.sql import and_, or_, not_
- from sqlalchemy import update
- from sqlalchemy import delete
- from passlib.hash import pbkdf2_sha256
- from sqlalchemy import *
- DK = pbkdf2_sha256.encrypt("key", round=100000, salt_size=16)
- Base = declarative_base()
- class User(Base):
- __tablename__ = 'user'
- # Here we define columns for the table user
- # Notice that each column is also a normal Python instance attribute.
- id = Column(Integer, primary_key=True)
- username = Column(types.Unicode(255), nullable=False)
- password = Column(types.Text(), default=DK, nullable=False)
- # Create an engine that stores data in the local directory's
- # sqlalchemy_example.db file.
- engine = create_engine('sqlite:///sqlalchemy_login.db')
- # Create all tables in the engine. This is equivalent to "Create Table"
- # statements in raw SQL.
- Base.metadata.create_all(engine)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement