File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -2450,12 +2450,18 @@ ensure that there is no open transaction:
24502450 using the :attr: `!autocommit ` attribute
24512451 before executing the ``PRAGMA `` statement:
24522452
2453- .. testcode ::
2453+ .. testcode ::
2454+ :hide:
2455+
2456+ con = sqlite3.connect(":memory: ", autocommit=False)
2457+
2458+ .. testcode ::
24542459
2455- saved = con.autocommit
2456- con.autocommit = True # Disable implicit transaction control.
2457- cur.execute("PRAGMA foreign_keys=ON")
2458- con.autocommit = saved # Restore the previous setting.
2460+ cur = con.cursor()
2461+ saved = con.autocommit
2462+ con.autocommit = True # Disable implicit transaction control.
2463+ cur.execute("PRAGMA foreign_keys=ON")
2464+ con.autocommit = saved # Restore the previous setting.
24592465
24602466
24612467.. _sqlite3-uri-tricks :
You can’t perform that action at this time.
0 commit comments