Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5866d94

Browse files
committed
Enable some sqlite and pysqlite options
- synchronous=normal (fewer disk writes, still safe in WAL mode) - foreign key enforcement - log sql statements at debug level - use sqlite3.Row (enables accessing columns by name)
1 parent bb2c85f commit 5866d94

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/dviread.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,17 @@ def __init__(self, filename=None):
10371037

10381038
self.connection = sqlite3.connect(
10391039
filename, isolation_level="DEFERRED")
1040+
if _log.isEnabledFor(logging.DEBUG):
1041+
def debug_sql(sql):
1042+
_log.debug(' '.join(sql.splitlines()).strip())
1043+
self.connection.set_trace_callback(debug_sql)
1044+
self.connection.row_factory = sqlite3.Row
10401045
with self.connection as conn:
1041-
conn.execute("PRAGMA journal_mode=WAL;")
1046+
conn.executescript("""
1047+
PRAGMA journal_mode=WAL;
1048+
PRAGMA synchronous=NORMAL;
1049+
PRAGMA foreign_keys=ON;
1050+
""")
10421051
version, = conn.execute("PRAGMA user_version;").fetchone()
10431052

10441053
if version == 0:

0 commit comments

Comments
 (0)