Collections, and installer patches

This commit is contained in:
Raelon Masters
2020-03-20 01:15:07 -04:00
parent 746dd405a8
commit 9327b01ff4
263 changed files with 509 additions and 365 deletions

0
src/backend/empty_bookshelf.sql vendored Normal file → Executable file
View File

0
src/backend/lib/display.py Normal file → Executable file
View File

View File

@@ -1,10 +1,5 @@
#!/usr/bin/python
import sqlite3
import psycopg2
from psycopg2 import Error
from .config import Config
# db_pointer = Config().catalogue_db
class Storage:
@@ -29,7 +24,6 @@ class Storage:
try:
self.cursor.execute(_q)
except Exception as e:
breakpoint()
if e.pgcode == "42501":
_q = """ALTER TABLE public.books OWNER to pyshelf;"""
self.close()
@@ -102,24 +96,29 @@ class Storage:
return True
def make_collections(self):
_q = "SELECT id,file_name FROM books"
_q = "SELECT id,file_name FROM books"
self.cursor.execute(_q)
_set = self.cursor.fetchall()
for book in _set:
path = self.config.book_path+'/'
path = self.config.book_path + "/"
_collections = []
_pathing = book[1].split(path)[1].split('/')
_pathing.pop(0);_pathing.pop(-1)
_pathing = book[1].split(path)[1].split("/")
_pathing.pop(0)
_pathing.pop(-1)
for _p in _pathing:
_s = _p.replace("'","")
_s = _p.replace("'", "")
_q_x = """
SELECT id FROM collections where collection='%s' AND book_id_id=%s
"""%(_s,book[0])
""" % (
_s,
book[0],
)
try:
self.cursor.execute(_q_x)
if len(self.cursor.fetchall()) < 1:
self.cursor.execute(
"""INSERT INTO collections (collection, book_id_id) VALUES ('%s',%s)"""%(_s,book[0])
"""INSERT INTO collections (collection, book_id_id) VALUES ('%s',%s)"""
% (_s, book[0])
)
except Exception as e:
print(e)