-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathdatabase.py
More file actions
20 lines (17 loc) · 751 Bytes
/
Copy pathdatabase.py
File metadata and controls
20 lines (17 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy import Column, DateTime, ForeignKey, Integer, Text, func, String
# Replace 'sqlite:///rfg.db' with your path to database
engine = create_engine('sqlite:///rfg.db', convert_unicode=True)
db_session = scoped_session(sessionmaker(autocommit=False,
autoflush=False,
bind=engine))
Base = declarative_base()
Base.query = db_session.query_property()
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(Text)
email = Column(Text)
username = Column(String(255))