sqlalchemy povezan z mysql, osnovna shema za card

master
Jan Kostanjevec 2022-05-02 14:17:05 +02:00
parent 2266189a6d
commit 278ed0f3e9
1 changed files with 17 additions and 20 deletions

View File

@ -1,41 +1,38 @@
#!/usr/bin/python3
from csv import unregister_dialect
import email
#import email
from sqlite3 import Date
from ssl import _PasswordType
from xmlrpc.client import DateTime
#from ssl import _PasswordType
#from xmlrpc.client import DateTime
#from matplotlib.pyplot import title
from sqlalchemy import Column, Integer, Float, String, Text, TIMESTAMP,ForeignKey
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
#from sqlalchemy.orm import relationship
from sqlalchemy import func, create_engine,join
from config import CONFIG
Base = declarative_base()
class USER(Base):
class User(Base):
__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)
# username = Column(String)
# password = Column(String) #mogoče raje kaj drugega, neki hash passworda al neki
# email = Column(String)
class Item(Base):
__tablename__ = 'item'
class Card(Base):
__tablename__ = 'card'
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)
class Interest(Base):
__tablename__ = 'interest'
pdf_id = Column(String, ForeignKey("item.id"), nullable=False)
user_id = Column(String, ForeignKey("user.id"), nullable=False)
title = Column(String(1024))
interest_rate = Column(Float)
owner_id = Column(Integer, ForeignKey("user.id"), nullable=False)
# shared = Column(Bool)
# item_location = Column(String)
# item_type = Column(String)
# item_size = Column(Integer)
#ali
# date_added = Column(String)
# last_review = Column(DateTime)