import sqlite3
def connect(dburi="cache.db"):
"""
Get database connection.
dburi: uri-style sqlite database filename; accepts certain ?= parameters.
"""
conn = sqlite3.connect(dburi, uri=True)
conn.row_factory = sqlite3.Row
conn.execute("PRAGMA journal_mode = WAL")
conn.execute("PRAGMA synchronous = 1") # less fsync, good for WAL mode
conn.execute("PRAGMA foreign_keys = ON")
return conn