2022-04-23 22:55:51 +02:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
2022-04-25 00:32:17 +02:00
|
|
|
from csv import unregister_dialect
|
2022-05-02 14:17:05 +02:00
|
|
|
#import email
|
2022-04-25 00:32:17 +02:00
|
|
|
from sqlite3 import Date
|
2022-06-04 22:18:21 +02:00
|
|
|
from xmlrpc.client import Boolean
|
2022-05-13 18:22:36 +02:00
|
|
|
from click import password_option
|
2022-06-04 22:18:21 +02:00
|
|
|
from pymysql import Timestamp
|
2022-05-02 14:17:05 +02:00
|
|
|
#from ssl import _PasswordType
|
|
|
|
#from xmlrpc.client import DateTime
|
|
|
|
#from matplotlib.pyplot import title
|
2022-06-04 22:18:21 +02:00
|
|
|
from sqlalchemy import Column, Integer, Float, String, Text, TIMESTAMP,ForeignKey, BOOLEAN
|
2022-04-23 22:55:51 +02:00
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
2022-05-02 14:17:05 +02:00
|
|
|
#from sqlalchemy.orm import relationship
|
2022-04-23 22:55:51 +02:00
|
|
|
from sqlalchemy import func, create_engine,join
|
|
|
|
from config import CONFIG
|
|
|
|
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
|
|
|
2022-05-02 14:17:05 +02:00
|
|
|
class User(Base):
|
2022-04-25 00:32:17 +02:00
|
|
|
__tablename__ = 'user'
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
2022-05-13 18:22:36 +02:00
|
|
|
username = Column(String(64))
|
|
|
|
password = Column(String(64))
|
2022-05-02 14:17:05 +02:00
|
|
|
# email = Column(String)
|
2022-05-18 14:08:35 +02:00
|
|
|
# config
|
|
|
|
# deck_size = Column(Integer)
|
2022-04-23 22:55:51 +02:00
|
|
|
|
|
|
|
|
2022-05-02 14:17:05 +02:00
|
|
|
class Card(Base):
|
|
|
|
__tablename__ = 'card'
|
2022-04-25 00:32:17 +02:00
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
2022-05-02 14:17:05 +02:00
|
|
|
title = Column(String(1024))
|
|
|
|
owner_id = Column(Integer, ForeignKey("user.id"), nullable=False)
|
2022-06-02 22:36:08 +02:00
|
|
|
interest_rate = Column(Float)
|
2022-06-03 19:12:14 +02:00
|
|
|
item_location = Column(String(1024))
|
2022-06-04 22:18:21 +02:00
|
|
|
#shared = Column(BOOLEAN) #tu bo že problem, ker
|
|
|
|
#last_review = Column(TIMESTAMP)
|
|
|
|
|
|
|
|
class Deck(Base):
|
|
|
|
__tablename__ = 'deck'
|
|
|
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
|
|
|
cards_by_id = Column(Text)
|
|
|
|
number_of_cards = Column(Integer)
|
|
|
|
current_card = Column(Integer)
|
|
|
|
completed = Column(BOOLEAN)
|
|
|
|
|
2022-06-02 22:36:08 +02:00
|
|
|
|
2022-05-02 14:17:05 +02:00
|
|
|
# shared = Column(Bool)
|
2022-05-18 14:08:35 +02:00
|
|
|
# item_type = Column(String)
|
|
|
|
# content_type = Column(String)
|
|
|
|
# item_size = Column(Integer)
|
2022-04-25 00:32:17 +02:00
|
|
|
#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)
|