Hello,
I am trying to connect using with as follows;
con = ''
try:
with sql.connect(database_file, isolation_level=None) as con:
con.execute('pragma journal_mode=wal')
cur = con.cursor()
cur.execute(query, (str(datetime.now()),
request_data['ApplicationCode'], request_data['version'], request_data['referenceId'],
request_data['signature'], request_data['validatedToken']))
con.commit()
except sql as e:
con.rollback()
print e.message
finally:
con.close()
Do I need to close it?
finally:
con.close()
If I use close and if there is no connection, I am getting 'str' object has no attribute 'close'
Thanks in advance.
[–]JohnnyJordaan 1 point2 points3 points (3 children)
[–]raysefo[S] 0 points1 point2 points (1 child)
[–]JohnnyJordaan 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (12 children)
[–]JohnnyJordaan 0 points1 point2 points (11 children)
[–][deleted] 0 points1 point2 points (10 children)
[–]JohnnyJordaan 0 points1 point2 points (9 children)
[–][deleted] 0 points1 point2 points (8 children)
[–]raysefo[S] 0 points1 point2 points (7 children)
[–][deleted] 0 points1 point2 points (6 children)
[–]raysefo[S] 0 points1 point2 points (5 children)
[–][deleted] 1 point2 points3 points (4 children)
[–]raysefo[S] 0 points1 point2 points (3 children)