Mercurial > p > roundup > code
comparison roundup/backends/sessions_sqlite.py @ 6930:a96a239db0d9
Set all sqlite db's to WAL mode on creation
Complete work done on 6917:fba76e0bba98.
WAL journaling mode now enabled on primary db as well as session db's
when using sqlite for session databases.
Made change to WAL mode more robust for testing by bracketing
`pragma journal_mode=wal` with commit() calls. Normally the conversion
would occur when a new session was opened, but this commits the changes
explicitly to make all the tests stable.
Also added doc on this.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Thu, 08 Sep 2022 01:12:12 -0400 |
| parents | fe0091279f50 |
| children |
comparison
equal
deleted
inserted
replaced
| 6929:581b09777eba | 6930:a96a239db0d9 |
|---|---|
| 34 # create table/rows etc. | 34 # create table/rows etc. |
| 35 self.sql('''CREATE TABLE %(name)ss (%(name)s_key VARCHAR(255), | 35 self.sql('''CREATE TABLE %(name)ss (%(name)s_key VARCHAR(255), |
| 36 %(name)s_value TEXT, %(name)s_time REAL)''' % {"name": self.name}) | 36 %(name)s_value TEXT, %(name)s_time REAL)''' % {"name": self.name}) |
| 37 self.sql('CREATE INDEX %(name)s_key_idx ON ' | 37 self.sql('CREATE INDEX %(name)s_key_idx ON ' |
| 38 '%(name)ss(%(name)s_key)' % {"name": self.name}) | 38 '%(name)ss(%(name)s_key)' % {"name": self.name}) |
| 39 self.commit() | 39 # Set journal mode to WAL. |
| 40 self.commit() # close out rollback journal/transaction | |
| 41 self.sql('pragma journal_mode=wal') # set wal | |
| 42 self.commit() # close out rollback and commit wal change | |
| 40 | 43 |
| 41 def sql(self, sql, args=None, cursor=None): | 44 def sql(self, sql, args=None, cursor=None): |
| 42 """ Execute the sql with the optional args. | 45 """ Execute the sql with the optional args. |
| 43 """ | 46 """ |
| 44 self.log_debug('SQL %r %r' % (sql, args)) | 47 self.log_debug('SQL %r %r' % (sql, args)) |
