Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User(DB.Model):
- __tablename__ = 'users'
- id = DB.Column(DB.Integer, primary_key=True)
- username = DB.Column(DB.String(64), index=True)
- password = DB.Column(DB.String(128))
- class Customer(DB.Model):
- __tablename__ = 'customer'
- customer_id = DB.Column(DB.Integer, primary_key=True)
- customer_name = DB.Column(DB.String, unique=True, index=True)
- SQLALCHEMY_BINDS = {
- 'customer1' = 'sqlite:////path/customer1.db',
- 'customer2' = 'sqlite:////path/customer2.db',
- ...
- }
- def get_session(customer_id):
- sqlite_url = 'sqlite:////path/customer%s.db' % customer_id
- engine = create_engine(sqlite_url)
- # initialize the db if it hasn't yet been initialized
- Base.metadata.create_all(engine)
- Session = sessionmaker(bind=engine)
- session = Session()
- return session
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement