-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataQueue.py
More file actions
35 lines (26 loc) · 896 Bytes
/
dataQueue.py
File metadata and controls
35 lines (26 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
create db file if not exists
create table
"""
from sqlalchemy import create_engine, Integer, String, ForeignKey, Column
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, relationship
import sqlalchemy.exc
import json
import logging
from logging.config import dictConfig
file = open('logging_config.ini', "r")
config = json.load(file)
dictConfig(config)
logger = logging.getLogger(__name__)
Base = declarative_base()
class User(Base):
__tablename__ = "person"
id = Column('id', Integer, primary_key=True, autoincrement=True)
username = Column('username', String, unique=True, nullable=True)
comment = Column('comment', String)
try:
engine = create_engine('sqlite:///users.db')
Base.metadata.create_all(bind=engine)
except sqlalchemy.exc.ArgumentError as e:
logger.error(e)