I am developing this program and for some reason, I keep getting this error. Is this an Ubuntu caused error, or something in my code that it crashing my program?
I am accessing a database and trying to remove the following characters from output: and, via value.translate(dictionary_of_bad_characters). That's where I get my error.
def get_data(plu): # Get the data needed
global value # Set the variable value to global
conn = sqlite3.connect('plus.sqlite') # Connect to the sqlite3 database
cursor = conn.cursor() # Set cursor as the cursor for plus.sqlite
results = cursor.execute('SELECT value FROM plus WHERE plu=?', [plu])
# Above code gets the data value for value with the PLU of plu
value = results.fetchone() # Get the results of value
data = [row[0] for row in results.fetchall()]
translation_table = dict.fromkeys(map(ord, '+-(),'), None)
# Above code creates a table with the mapped characters
value = value.translate(translation_table)
# Above code removes any unnescessary characters from value
response = { 'PLU': plu,
'Value': value
} # Create the response variable
value = int(value) # Convert value to type integer
cursor.close() # Close the cursor
conn.close() # Close the connection
return(value) # Return to the program flow