def do_create_titles(): c = conn.cursor() c.execute("SELECT id, title FROM " + db_prefix + "books") d = conn.cursor() for row in c: initial = lucicat_utils.get_initial(config, row[1]) d.execute("DELETE FROM " + db_prefix + "titles WHERE book = " + ph, (row[0], )) d.execute( "INSERT INTO " + db_prefix + "titles (book, initial) VALUES (" + ph + ", " + ph + ")", (row[0], initial)) d.close() c.close() conn.commit()
def do_create_authors(): c = conn.cursor() c.execute("SELECT id, name, file_as FROM " + db_prefix + "authors") d = conn.cursor() for row in c: file_as = row[2] if not file_as: file_as = row[1] initial = lucicat_utils.get_initial(config, file_as) d.execute( "UPDATE " + db_prefix + "authors SET file_as = " + ph + ", initial = " + ph + " WHERE id=" + ph, (file_as, initial, row[0])) d.close() c.close() conn.commit()
+ " OR uri IS NULL AND " + ph + " IS NULL)" + " AND (email=" + ph + " OR email IS NULL AND " + ph + " IS NULL)", (aut["name"], aut["uri"], aut["uri"], aut["email"], aut["email"]), ) row = c.fetchone() author_id = -1 if row: author_id = row[0] else: initial = lucicat_utils.get_initial(config, aut["file-as"]) c.execute( "INSERT INTO " + db_prefix + "authors (id, name, uri, email, file_as, initial) VALUES (NULL" + (", " + ph) * 5 + ")", (aut["name"], aut["uri"], aut["email"], aut["file-as"], initial), ) author_id = c.lastrowid c.execute( "INSERT INTO " + db_prefix + "authors_books (id, author, book) VALUES (NULL" + (", " + ph) * 2 + ")",
book_id = c.lastrowid for aut in authors: c.execute( "SELECT * FROM " + db_prefix + "authors WHERE name=" + ph + " AND (uri=" + ph + " OR uri IS NULL AND " + ph + " IS NULL)" + " AND (email=" + ph + " OR email IS NULL AND " + ph + " IS NULL)", (aut["name"], aut["uri"], aut["uri"], aut["email"], aut["email"])) row = c.fetchone() author_id = -1 if row: author_id = row[0] else: initial = lucicat_utils.get_initial(config, aut["file-as"]) c.execute( "INSERT INTO " + db_prefix + "authors (id, name, uri, email, file_as, initial) VALUES (NULL" + (", " + ph) * 5 + ")", (aut["name"], aut["uri"], aut["email"], aut["file-as"], initial)) author_id = c.lastrowid c.execute( "INSERT INTO " + db_prefix + "authors_books (id, author, book) VALUES (NULL" + (", " + ph) * 2 + ")", (author_id, book_id)) for link in links: c.execute( "INSERT INTO " + db_prefix +