mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Reduce sqlalchemy reflection overhead at recorder setup time (#113989)
This commit is contained in:
parent
7b0abb00aa
commit
de62b7774f
@ -6,7 +6,7 @@ from collections.abc import Iterable, Mapping
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlalchemy import MetaData
|
||||
from sqlalchemy import MetaData, Table
|
||||
from sqlalchemy.exc import OperationalError
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
from sqlalchemy.orm.attributes import InstrumentedAttribute
|
||||
@ -94,9 +94,9 @@ def _validate_table_schema_has_correct_collation(
|
||||
with session_scope(session=instance.get_session(), read_only=True) as session:
|
||||
table = table_object.__tablename__
|
||||
metadata_obj = MetaData()
|
||||
reflected_table = Table(table, metadata_obj, autoload_with=instance.engine)
|
||||
connection = session.connection()
|
||||
metadata_obj.reflect(bind=connection)
|
||||
dialect_kwargs = metadata_obj.tables[table].dialect_kwargs
|
||||
dialect_kwargs = reflected_table.dialect_kwargs
|
||||
# Check if the table has a collation set, if its not set than its
|
||||
# using the server default collation for the database
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user