1
I am using Python and giving import of sqlite3 library and sqlite3 giving import in Error for exception handling!
import sqlite3
from sqlite3 import Error
def errorlog(erro):
errlog = open("err_log.txt", 'a')
errlog.write(erro)
errlog.close()
def conexaoBanco():
con = None
try:
con = sqlite3.connect('banco.db')
except Error as er:
errorlog(er)
return con
However the variable er does not contain a string! generating this error:
TypeError: write() argument must be str, not OperationalError
That’s what the error message says, the function argument should be
str
and not an instance ofOperationalError
. Testingerrlog.write(erro.message)
– Augusto Vasques