sqlalchemy povezan z mysql, osnovna shema za card
parent
2266189a6d
commit
278ed0f3e9
37
create_db.py
37
create_db.py
|
@ -1,41 +1,38 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
from csv import unregister_dialect
|
from csv import unregister_dialect
|
||||||
import email
|
#import email
|
||||||
from sqlite3 import Date
|
from sqlite3 import Date
|
||||||
from ssl import _PasswordType
|
#from ssl import _PasswordType
|
||||||
from xmlrpc.client import DateTime
|
#from xmlrpc.client import DateTime
|
||||||
|
#from matplotlib.pyplot import title
|
||||||
from sqlalchemy import Column, Integer, Float, String, Text, TIMESTAMP,ForeignKey
|
from sqlalchemy import Column, Integer, Float, String, Text, TIMESTAMP,ForeignKey
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
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 sqlalchemy import func, create_engine,join
|
||||||
from config import CONFIG
|
from config import CONFIG
|
||||||
|
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
|
|
||||||
class USER(Base):
|
class User(Base):
|
||||||
__tablename__ = 'user'
|
__tablename__ = 'user'
|
||||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
username = Column(String)
|
# username = Column(String)
|
||||||
password = Column(String) #mogoče raje kaj drugega, neki hash passworda al neki
|
# password = Column(String) #mogoče raje kaj drugega, neki hash passworda al neki
|
||||||
email = Column(String)
|
# email = Column(String)
|
||||||
|
|
||||||
|
|
||||||
class Item(Base):
|
class Card(Base):
|
||||||
__tablename__ = 'item'
|
__tablename__ = 'card'
|
||||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||||
owner_id = Column(String, ForeignKey("user.id"), nullable=False)
|
title = Column(String(1024))
|
||||||
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)
|
|
||||||
interest_rate = Column(Float)
|
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
|
#ali
|
||||||
# date_added = Column(String)
|
# date_added = Column(String)
|
||||||
# last_review = Column(DateTime)
|
# last_review = Column(DateTime)
|
||||||
|
|
Loading…
Reference in New Issue