code: def set_up(self, u, engine):
          
          def connect_listener_enable_fk(connection, record):
              # fk must be enabled for all connections
              if not getattr(engine, "fk_disabled", False):
                  return  # http://trac.buildbot.net/ticket/3490#ticket
                  # connection.execute('pragma foreign_keys=ON')
  
          sa.event.listen(engine.pool, 'connect', connect_listener_enable_fk)
          # try to enable WAL logging
          if u.database:
              def connect_listener(connection, record):
                  connection.execute("pragma checkpoint_fullfsync = off")
  
              sa.event.listen(engine.pool, 'connect', connect_listener)
  
              log.msg("setting database journal mode to 'wal'")
              try:
                  engine.execute("pragma journal_mode = wal")
              except Exception:
                  log.msg("failed to set journal mode - database may fail")
docs: Special setup for sqlite engines