1
0
Fork 0
mirror of https://github.com/evilhero/mylar synced 2024-12-24 08:42:37 +00:00

FIX:(#397) Recreate pullist would error on recreation (rupaschomaker), IMP:(#395) Log SQL execution on operational error (rupaschomaker)

This commit is contained in:
evilhero 2013-05-19 00:09:51 -04:00
parent d0c6eb1d52
commit 64a1f44163
2 changed files with 10 additions and 5 deletions

View file

@ -69,7 +69,7 @@ class DBConnection:
attempt += 1 attempt += 1
time.sleep(1) time.sleep(1)
else: else:
logger.error('Database error: %s' % e) logger.error('Database error executing %s :: %s' % (query, e))
raise raise
except sqlite3.DatabaseError, e: except sqlite3.DatabaseError, e:
logger.error('Fatal Error executing %s :: %s' % (query, e)) logger.error('Fatal Error executing %s :: %s' % (query, e))

View file

@ -37,14 +37,18 @@ def pullit(forcecheck=None):
try: try:
pull_date = myDB.action("SELECT SHIPDATE from weekly").fetchone() pull_date = myDB.action("SELECT SHIPDATE from weekly").fetchone()
logger.info(u"Weekly pull list present - checking if it's up-to-date..") logger.info(u"Weekly pull list present - checking if it's up-to-date..")
if (pull_date is None):
pulldate = '00000000'
else:
pulldate = pull_date['SHIPDATE'] pulldate = pull_date['SHIPDATE']
except (sqlite3.OperationalError, TypeError),msg: except (sqlite3.OperationalError, TypeError),msg:
conn=sqlite3.connect(mylar.DB_FILE) conn=sqlite3.connect(mylar.DB_FILE)
c=conn.cursor() c=conn.cursor()
logger.info(u"Error Retrieving weekly pull list - attempting to adjust") logger.info(u"Error Retrieving weekly pull list - attempting to adjust")
c.execute('DROP TABLE weekly') c.execute('DROP TABLE weekly')
c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE text, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text)') c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE text, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text, ComicID text)')
pulldate = '00000000' pulldate = '00000000'
logger.fdebug(u"Table re-created, trying to populate")
else: else:
logger.info(u"No pullist found...I'm going to try and get a new list now.") logger.info(u"No pullist found...I'm going to try and get a new list now.")
pulldate = '00000000' pulldate = '00000000'
@ -304,7 +308,7 @@ def pullit(forcecheck=None):
cursor.executescript('drop table if exists weekly;') cursor.executescript('drop table if exists weekly;')
cursor.execute("CREATE TABLE IF NOT EXISTS weekly (SHIPDATE, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text);") cursor.execute("CREATE TABLE IF NOT EXISTS weekly (SHIPDATE, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text, ComicID text);")
connection.commit() connection.commit()
@ -318,7 +322,8 @@ def pullit(forcecheck=None):
if "BOOK" in row: break if "BOOK" in row: break
#print (row) #print (row)
try: try:
cursor.execute("INSERT INTO weekly VALUES (?,?,?,?,?,?);", row) logger.debug("Row: %s" % row)
cursor.execute("INSERT INTO weekly VALUES (?,?,?,?,?,?,null);", row)
except Exception, e: except Exception, e:
#print ("Error - invald arguments...-skipping") #print ("Error - invald arguments...-skipping")
pass pass