def SortName(name):
if database:
c = database.cursor()
- c.execute('SELECT metadata.SortStr(%s)', (name))
+ c.execute('SELECT metadata.SortStr(%s)', [name])
return c.fetchone()[0]
else:
print "No connection to DB"
def SortAuthorName(name):
if database:
c = database.cursor()
- c.execute('SELECT metadata.SortAuthor(%s)', (name))
+ c.execute('SELECT metadata.SortAuthor(%s)', [name])
return c.fetchone()[0]
else:
print "No connection to DB"
def GetOrCreateAuthor(name):
if database:
c = database.cursor()
- c.execute('SELECT metadata.GetOrCreateAuthor(%s)', (name))
+ c.execute('SELECT metadata.GetOrCreateAuthor(%s)', [name])
return c.fetchone()[0]
else:
print "No connection to DB"
def GetOrCreateLang(name):
if database:
c = database.cursor()
- c.execute('SELECT metadata.GetOrCreateLang(%s)', (name))
+ c.execute('SELECT metadata.GetOrCreateLang(%s)', [name])
return c.fetchone()[0]
else:
print "No connection to DB"
def GetOrCreatePublisher(name):
if database:
c = database.cursor()
- c.execute('SELECT metadata.GetOrCreatePublisher(%s)', (name))
+ c.execute('SELECT metadata.GetOrCreatePublisher(%s)', [name])
return c.fetchone()[0]
else:
print "No connection to DB"
def GetOrCreateSeries(name):
if database:
c = database.cursor()
- c.execute('SELECT metadata.GetOrCreateSeries(%s)', (name))
+ c.execute('SELECT metadata.GetOrCreateSeries(%s)', [name])
return c.fetchone()[0]
else:
print "No connection to DB"
def GetOrCreateTag(name):
if database:
c = database.cursor()
- c.execute('SELECT metadata.GetOrCreateTag(%s)', (name))
+ c.execute('SELECT metadata.GetOrCreateTag(%s)', [name])
return c.fetchone()[0]
else:
print "No connection to DB"
def CreateBook(title,pubdate,series_index,isbn):
if database:
c = database.cursor()
- c.execute('SELECT metadata.CreateBook(%s,%s,%s,%s)', (title,pubdate,series_index,isbn))
+ c.execute('SELECT metadata.CreateBook(%s,%s,%s,%s)', [title,pubdate,series_index,isbn])
return c.fetchone()[0]
else:
print "No connection to DB"
if database:
c = database.cursor()
for author_id in author_ids:
- c.execute('INSERT INTO metadata.books_authors_link(book,author) VALUES (%s,%s)', (book_id,author_id))
+ c.execute('INSERT INTO metadata.books_authors_link(book,author) VALUES (%s,%s)', [book_id,author_id])
else:
print "No connection to DB"
exit()
io = 0
for lang_id in lang_ids:
io = io + 1
- c.execute('INSERT INTO metadata.books_languages_link(book,lang_code,item_order) VALUES (%s,%s,%s)', (book_id,lang_id,io))
+ c.execute('INSERT INTO metadata.books_languages_link(book,lang_code,item_order) VALUES (%s,%s,%s)', [book_id,lang_id,io])
else:
print "No connection to DB"
exit()
def LinkBookToPublishers(book_id,pub_id):
if database:
c = database.cursor()
- c.execute('INSERT INTO metadata.books_publishers_link(book,publisher) VALUES (%s,%s)', (book_id,pub_id))
+ c.execute('INSERT INTO metadata.books_publishers_link(book,publisher) VALUES (%s,%s)', [book_id,pub_id])
else:
print "No connection to DB"
exit()
def LinkBookToSeries(book_id,ser_id):
if database:
c = database.cursor()
- c.execute('INSERT INTO metadata.books_series_link(book,series) VALUES (%s,%s)', (book_id,ser_id))
+ c.execute('INSERT INTO metadata.books_series_link(book,series) VALUES (%s,%s)', [book_id,ser_id])
else:
print "No connection to DB"
exit()
if database:
c = database.cursor()
for tag_id in tag_ids:
- c.execute('INSERT INTO metadata.books_tags_link(book,tag) VALUES (%s,%s)', (book_id,tag_id))
+ c.execute('INSERT INTO metadata.books_tags_link(book,tag) VALUES (%s,%s)', [book_id,tag_id])
else:
print "No connection to DB"
exit()
def SetPath(book_id,path,dataname,filesize,cover):
if database:
c = database.cursor()
- c.execute('UPDATE metadata.books SET path=%s, has_cover=%s WHERE id=%s', (path,cover,book_id))
- c.execute('INSERT INTO metadata.data(book,format,uncompressed_size,name) values (%s,%s,%s,%s)',(book_id,'FB2',filesize,dataname))
+ c.execute('UPDATE metadata.books SET path=%s, has_cover=%s WHERE id=%s', [path,cover,book_id])
+ c.execute('INSERT INTO metadata.data(book,format,uncompressed_size,name) values (%s,%s,%s,%s)',[book_id,'FB2',filesize,dataname])
else:
print "No connection to DB"
exit()
def StoreComment(book_id,comment):
if database:
c = database.cursor()
- c.execute('INSERT INTO metadata.comments(book,text) values (%s,%s)',(book_id,comment))
+ c.execute('INSERT INTO metadata.comments(book,text) values (%s,%s)',[book_id,comment])
else:
print "No connection to DB"
exit()
def PathByID(book_id):
if database:
c = database.cursor()
- c.execute('SELECT path FROM metadata.books WHERE id=%s',(book_id))
+ c.execute('SELECT path FROM metadata.books WHERE id=%s',[book_id])
return c.fetchone()[0]
else:
print "No connection to DB"
def DataByID(book_id,format):
if database:
c = database.cursor()
- c.execute('SELECT name FROM metadata.data WHERE book=%s and format=%s',(book_id,format))
+ c.execute('SELECT name FROM metadata.data WHERE book=%s and format=%s',[book_id,format])
return c.fetchone()[0]+'.'+format.lower()
else:
print "No connection to DB"
def DelBook(book_id):
if database:
c = database.cursor()
- c.execute('DELETE FROM metadata.books WHERE id=%s',(book_id))
+ c.execute('DELETE FROM metadata.books WHERE id=%s',[book_id])
else:
print "No connection to DB"
exit()
def ChangeBookFormat(book_id,old_format,new_format):
if database:
c = database.cursor()
- c.execute('UPDATE metadata.data SET format=%s WHERE book=%s and format=%s',(new_format,book_id,old_format))
+ c.execute('UPDATE metadata.data SET format=%s WHERE book=%s and format=%s',[new_format,book_id,old_format])
else:
print "No connection to DB"
exit()
def TestArchive(name):
if database:
c = database.cursor()
- c.execute('SELECT count(*) from metadata.processed_archives WHERE filename=%s',(name))
+ c.execute('SELECT count(*) from metadata.processed_archives WHERE filename=%s',[name])
return c.fetchone()[0]
else:
print "No connection to DB"
def MarkArchive(name):
if database:
c = database.cursor()
- c.execute('insert into metadata.processed_archives(filename) values (%s)',(name))
+ c.execute('insert into metadata.processed_archives(filename) values (%s)',[name])
else:
print "No connection to DB"
exit()
def ListByFormat(format,limit=100):
if database:
c = database.cursor()
- c.execute('SELECT DISTINCT book FROM metadata.data WHERE format=%s ORDER BY book LIMIT 0,%s',(format,limit))
+ c.execute('SELECT DISTINCT book FROM metadata.data WHERE format=%s ORDER BY book LIMIT 0,%s',[format,limit])
return c.fetchall()
else:
print "No connection to DB"
def ListDups(limit=100):
if database:
c = database.cursor()
- c.execute('SELECT b.title,l.author,max(b.id) id FROM metadata.books b,metadata.books_authors_link l where b.id=l.book group by b.title,l.author having count(*)>%s',(limit))
+ c.execute('SELECT b.title,l.author,max(b.id) id FROM metadata.books b,metadata.books_authors_link l where b.id=l.book group by b.title,l.author having count(*)>%s',[limit])
return c.fetchall()
else:
print "No connection to DB"
def ListByTitleAndAuthor(title,author,id=0):
if database:
c = database.cursor()
- c.execute('SELECT b.id FROM metadata.books b,metadata.books_authors_link l where b.id=l.book and b.title=%s and l.author=%s and b.id<>%s',(title,author,id))
+ c.execute('SELECT b.id FROM metadata.books b,metadata.books_authors_link l where b.id=l.book and b.title=%s and l.author=%s and b.id<>%s',[title,author,id])
return c.fetchall()
else:
print "No connection to DB"