ChatterBot: (sqlite3.OperationalError) cannot change into wal mode from within a transaction

>>> bot = ChatBot('new man')

Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\engine\base.py", line 2147, in _wrap_pool_connect
    return fn()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 387, in connect
    return _ConnectionFairy._checkout(self)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 766, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 516, in checkout
    rec = pool._do_get()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 1229, in _do_get
    return self._create_connection()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 333, in _create_connection
    return _ConnectionRecord(self)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 461, in __init__
    self.__connect(first_connect_check=True)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 663, in __connect
    pool.dispatch.connect(self.connection, self)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\event\attr.py", line 218, in __call__
    fn(*args, **kw)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\chatterbot\storage\sql_storage.py", line 70, in set_sqlite_pragma
    dbapi_connection.execute('PRAGMA journal_mode=WAL')
sqlite3.OperationalError: cannot change into wal mode from within a transaction

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    bot = ChatBot('new man')
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\chatterbot\chatterbot.py", line 39, in __init__
    self.storage = utils.initialize_class(storage_adapter, **kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\chatterbot\utils.py", line 33, in initialize_class
    return Class(**kwargs)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\chatterbot\storage\sql_storage.py", line 77, in __init__
    if not self.engine.dialect.has_table(self.engine, 'Statement'):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\dialects\sqlite\base.py", line 1181, in has_table
    connection, "table_info", table_name, schema=schema)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\dialects\sqlite\base.py", line 1572, in _get_table_pragma
    cursor = connection.execute(statement)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\engine\base.py", line 2063, in execute
    connection = self.contextual_connect(close_with_result=True)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\engine\base.py", line 2112, in contextual_connect
    self._wrap_pool_connect(self.pool.connect, None),
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\engine\base.py", line 2151, in _wrap_pool_connect
    e, dialect, self)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\engine\base.py", line 1465, in _handle_dbapi_exception_noconnection
    exc_info
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\util\compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\util\compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\engine\base.py", line 2147, in _wrap_pool_connect
    return fn()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 387, in connect
    return _ConnectionFairy._checkout(self)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 766, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 516, in checkout
    rec = pool._do_get()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 1229, in _do_get
    return self._create_connection()
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 333, in _create_connection
    return _ConnectionRecord(self)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 461, in __init__
    self.__connect(first_connect_check=True)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\pool.py", line 663, in __connect
    pool.dispatch.connect(self.connection, self)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sqlalchemy\event\attr.py", line 218, in __call__
    fn(*args, **kw)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\chatterbot\storage\sql_storage.py", line 70, in set_sqlite_pragma
    dbapi_connection.execute('PRAGMA journal_mode=WAL')
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) cannot change into wal mode from within a transaction

>>> bot = ChatBot('new man')
after this states 

(sqlite3.OperationalError) cannot change into wal mode from within a transaction

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 1
  • Comments: 23 (5 by maintainers)

Most upvoted comments

@mohitatgithub pip install --upgrade chatterbot==0.7.4

I am using pythonanywhere python 3.6 and the error thrown looks similar to the one posted by Feekee at the top.

The ChatBot object does not get initialized for some reasons. Amazing library by the way 👍

screen shot 2018-11-27 at 8 53 18 am

@gunthercox Just tried to reproduce the error with newer versions, seems that 0.7.4 is the latest release without the error. Problem starts occurring in version 0.7.5.

I am trapped in this problem in a virtualenv environment, while it can run without error with macos system python3.

@chamkank Thank you. That might prove helpful in tracking down the cause.