contentmatcher/create_db.py

50 lines
1.5 KiB
Python
Raw Normal View History

2022-04-23 22:55:51 +02:00
#!/usr/bin/python3
2022-04-25 00:32:17 +02:00
from csv import unregister_dialect
import email
from sqlite3 import Date
from ssl import _PasswordType
from xmlrpc.client import DateTime
2022-04-23 22:55:51 +02:00
from sqlalchemy import Column, Integer, Float, String, Text, TIMESTAMP,ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import func, create_engine,join
from config import CONFIG
Base = declarative_base()
class USER(Base):
2022-04-25 00:32:17 +02:00
__tablename__ = 'user'
id = Column(Integer, primary_key=True, autoincrement=True)
username = Column(String)
password = Column(String) #mogoče raje kaj drugega, neki hash passworda al neki
email = Column(String)
2022-04-23 22:55:51 +02:00
class Item(Base):
2022-04-25 00:32:17 +02:00
__tablename__ = 'item'
id = Column(Integer, primary_key=True, autoincrement=True)
owner_id = Column(String, ForeignKey("user.id"), nullable=False)
item_location = Column(String)
item_type = Column(String)
item_size = Column(Integer)
2022-04-23 22:55:51 +02:00
class Interest(Base):
2022-04-25 00:32:17 +02:00
__tablename__ = 'interest'
pdf_id = Column(String, ForeignKey("item.id"), nullable=False)
user_id = Column(String, ForeignKey("user.id"), nullable=False)
interest_rate = Column(Float)
#ali
# date_added = Column(String)
# last_review = Column(DateTime)
# interval = Column(Integer)
# due = Column(DateTime)
2022-04-23 22:55:51 +02:00
engine = create_engine(CONFIG['DB_CONNECTION'])
Base.metadata.create_all(engine)