2022-05-02 14:15:51 +02:00
|
|
|
"""from newxtloud get a list of titles to populate DB"""
|
|
|
|
|
|
|
|
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()
|
2022-06-14 14:03:29 +02:00
|
|
|
session.close()
|
2022-05-02 14:15:51 +02:00
|
|
|
|
|
|
|
id = id+1
|