Compare commits
2 Commits
7a0109916e
...
278ed0f3e9
Author | SHA1 | Date |
---|---|---|
Jan Kostanjevec | 278ed0f3e9 | |
Jan Kostanjevec | 2266189a6d |
37
create_db.py
37
create_db.py
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from webdav3.client import Client
|
||||
|
||||
options = {
|
||||
#'webdav_login': 'gia',
|
||||
#'webdav_password': 'gia0000!',
|
||||
'webdav_token': '2WmQL-G7Jbg-6t7sN-JBRSe-eBGy5',
|
||||
'webdav_hostname': 'https://obzorje.kompot.si/remote.php/dav/files/dab82616-284e-103c-9287-6de9b1978576/'
|
||||
#'webdav_hostname': 'https://obzorje.kompot.si',
|
||||
#'webdav_root': '/remote.php/dav/files/'
|
||||
}
|
||||
|
||||
client = Client(options)
|
||||
|
||||
def get_file_list():
|
||||
return client.list("/GIA CLOUD")
|
|
@ -0,0 +1,30 @@
|
|||
"""from newxtloud get a list of titles to populate DB"""
|
||||
|
||||
import imp
|
||||
from requests import session
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from config import CONFIG
|
||||
from create_db import Base, Card
|
||||
|
||||
from get_files import get_file_list
|
||||
|
||||
engine = create_engine(CONFIG['DB_CONNECTION'])
|
||||
Base.metadata.bind = engine
|
||||
DBSsession = sessionmaker(bind=engine)
|
||||
session = DBSsession()
|
||||
|
||||
l = get_file_list()
|
||||
id = 0 #TODO
|
||||
for title in l:
|
||||
if title[-4:] == ".pdf":
|
||||
card = Card(
|
||||
id=id,
|
||||
title=title[:-4],
|
||||
interest_rate=-1,
|
||||
owner_id = 1
|
||||
)
|
||||
session.add(card)
|
||||
session.commit()
|
||||
|
||||
id = id+1
|
Loading…
Reference in New Issue