def checkItemNameExists(name): name = name.lower() try: command = "SELECT [name] from {tableName} WHERE [name] LIKE '{itemName}'"\ .format(tableName=ITEM_NAME_LIST_TABLE_NAME, itemName=name) cursor.execute(command) return len(cursor.fetchall()) > 0 except sqlite3.Error as e: print("ERROR_LOCAL_DB", e) debug_log.addLog("ERROR_LOCAL_DB" + str(e))
def addNewItemName(name, itemId=-1): try: name = name.replace("'", "") command = """INSERT INTO %s (name, _id) VALUES ('%s', %d)""" % (ITEM_NAME_LIST_TABLE_NAME, name, itemId) cursor.execute(command) connection.commit() #debug_log.addLog("LOCAL_DB", "New item NAME added " + name + " to " + ITEM_NAME_LIST_TABLE_NAME) except sqlite3.IntegrityError as e: print(e) debug_log.addLog("ERROR_LOCAL_DB " + str(e)) return e return name, " added"
def deleteSeenItem(_id): try: command = "DELETE from %s where _id = %d" % (SEEN_PRICE_TABLE_NAME, _id) cursor.execute(command) connection.commit() debug_log.addLog( "LOCAL_DB", "DELETED item of id:" + str(_id) + " from " + SEEN_PRICE_TABLE_NAME) except sqlite3.IntegrityError as e: print(e) debug_log.addLog("ERROR_LOCAL_DB" + e) return e
def addSeenItem(name, seenAs, price, quantity, location, person): ts = calendar.timegm(time.gmtime()) try: command = f"INSERT INTO {SEEN_PRICE_TABLE_NAME} VALUES (null, '{name}', " \ f"'{seenAs}', {price}, {quantity}, {ts}, '{location}', '{person}')" cursor.execute(command) connection.commit() debug_log.addLog( "LOCAL_DB", "New seen item added " + name + " to " + SEEN_PRICE_TABLE_NAME) except sqlite3.IntegrityError as e: print(e) debug_log.addLog("ERROR_LOCAL_DB" + e) return e return name + " has been added, Price:" + str(price)
def on_press(keyInfo): if app_variables.gatherDataOn: print("Gathering screen data...") # Capturing img debug_log.addLog("KEYBOARD", "Capture key was pressed.") img_parse.captureRawImg()