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

Skip to content

Commit 3ce3061

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 2124ac8 commit 3ce3061

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
@@ -1039,8 +1039,17 @@ def __init__(self, filename=None):
10391039

10401040
self.connection = sqlite3.connect(
10411041
filename, isolation_level="DEFERRED")
1042+
if _log.isEnabledFor(logging.DEBUG):
1043+
def debug_sql(sql):
1044+
_log.debug(' '.join(sql.splitlines()).strip())
1045+
self.connection.set_trace_callback(debug_sql)
1046+
self.connection.row_factory = sqlite3.Row
10421047
with self.connection as conn:
1043-
conn.execute("PRAGMA journal_mode=WAL;")
1048+
conn.executescript("""
1049+
PRAGMA journal_mode=WAL;
1050+
PRAGMA synchronous=NORMAL;
1051+
PRAGMA foreign_keys=ON;
1052+
""")
10441053
version, = conn.execute("PRAGMA user_version;").fetchone()
10451054

10461055
if version == 0:

0 commit comments

Comments
 (0)