mirror of
https://git.yoctoproject.org/poky
synced 2026-06-03 13:49:49 +00:00
bitbake: hashserv: Fix deprecation warning about sqlite adapter
The default adapters for sqlite datetime are deprecated as of Python 3.12, so implement our own. [YOCTO #15333] (Bitbake rev: 38a1d715bf58acbc9cb21eed413b3542c81cf15a) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
b48273775f
commit
396e45480e
@@ -4,6 +4,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
#
|
#
|
||||||
|
from datetime import datetime, timezone
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import logging
|
import logging
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
@@ -53,6 +54,22 @@ CONFIG_TABLE_DEFINITION = (
|
|||||||
CONFIG_TABLE_COLUMNS = tuple(name for name, _, _ in CONFIG_TABLE_DEFINITION)
|
CONFIG_TABLE_COLUMNS = tuple(name for name, _, _ in CONFIG_TABLE_DEFINITION)
|
||||||
|
|
||||||
|
|
||||||
|
def adapt_datetime_iso(val):
|
||||||
|
"""Adapt datetime.datetime to UTC ISO 8601 date."""
|
||||||
|
return val.astimezone(timezone.utc).isoformat()
|
||||||
|
|
||||||
|
|
||||||
|
sqlite3.register_adapter(datetime, adapt_datetime_iso)
|
||||||
|
|
||||||
|
|
||||||
|
def convert_datetime(val):
|
||||||
|
"""Convert ISO 8601 datetime to datetime.datetime object."""
|
||||||
|
return datetime.fromisoformat(val.decode())
|
||||||
|
|
||||||
|
|
||||||
|
sqlite3.register_converter("DATETIME", convert_datetime)
|
||||||
|
|
||||||
|
|
||||||
def _make_table(cursor, name, definition):
|
def _make_table(cursor, name, definition):
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user