I'm having issues using the method I made to connect to my sqlite db. I get an error of 'NoneType' object has no attribute 'cursor', when i call connect_db() below:
When i try to use connect_db()
def connect_db(dbname):
try:
dbconn = sqlite3.connect(dbname)
except:
print ("error connecting to db")
It throws the error here:
#save to database
dbconn = connect_db('./syncdb.db')
cursor = dbconn.cursor()
cursor.execute('''
CREATE TABLE paths (
id INTEGER PRIMARY KEY,
source TEXT,
destination TEXT
)
''')
Anyone know what I'm doing wrong? I've tried a lot of different ways already to use this method connect_db(), but it doesnt seem to be able to work correctly.
Thank you.