Recorder: Extra check to incoming connections which could be not sqlite3 ones (#9867)
* Extra check to incoming connections The incoming connection could be other than self.db_url, because some 'custom_component' could be making these, and then, if they're not sqlite3 connections, an error will raise because those haven't the `dbapi_connection.isolation_level` attrib. * lint fix * simplify check: isinstance test onlypull/9920/head
parent
ed70fc9322
commit
e57d0f345e
|
@ -351,6 +351,7 @@ class Recorder(threading.Thread):
|
|||
from sqlalchemy.engine import Engine
|
||||
from sqlalchemy.orm import scoped_session
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from sqlite3 import Connection
|
||||
|
||||
from . import models
|
||||
|
||||
|
@ -360,7 +361,7 @@ class Recorder(threading.Thread):
|
|||
@event.listens_for(Engine, "connect")
|
||||
def set_sqlite_pragma(dbapi_connection, connection_record):
|
||||
"""Set sqlite's WAL mode."""
|
||||
if self.db_url.startswith("sqlite://"):
|
||||
if isinstance(dbapi_connection, Connection):
|
||||
old_isolation = dbapi_connection.isolation_level
|
||||
dbapi_connection.isolation_level = None
|
||||
cursor = dbapi_connection.cursor()
|
||||
|
|
Loading…
Reference in New Issue