Home Assistant Unofficial Reference
2024.12.1
sqlite.py
Go to the documentation of this file.
1
"""Provide info to system health for sqlite."""
2
3
from
__future__
import
annotations
4
5
from
sqlalchemy
import
text
6
from
sqlalchemy.orm.session
import
Session
7
8
9
def
db_size_bytes
(session: Session, database_name: str) -> float |
None
:
10
"""Get the mysql database size."""
11
size = session.execute(
12
text(
13
"SELECT page_count * page_size as size "
14
"FROM pragma_page_count(), pragma_page_size();"
15
)
16
).scalar()
17
18
if
not
size:
19
return
None
20
21
return
float
(size)
homeassistant.components.airq.const.float
float
Definition:
const.py:11
homeassistant.components.recorder.system_health.sqlite.db_size_bytes
float|None db_size_bytes(Session session, str database_name)
Definition:
sqlite.py:9
core
homeassistant
components
recorder
system_health
sqlite.py
Generated by
1.9.1