mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-90016: Deprecate default sqlite3 adapters and converters (#94276)
Co-authored-by: CAM Gerlach <CAM.Gerlach@Gerlach.CAM>
This commit is contained in:
parent
000a4eebe7
commit
6dadf6ca01
7 changed files with 66 additions and 49 deletions
|
@ -55,16 +55,25 @@ Binary = memoryview
|
|||
collections.abc.Sequence.register(Row)
|
||||
|
||||
def register_adapters_and_converters():
|
||||
from warnings import warn
|
||||
|
||||
msg = ("The default {what} is deprecated as of Python 3.12; "
|
||||
"see the sqlite3 documentation for suggested replacement recipes")
|
||||
|
||||
def adapt_date(val):
|
||||
warn(msg.format(what="date adapter"), DeprecationWarning, stacklevel=2)
|
||||
return val.isoformat()
|
||||
|
||||
def adapt_datetime(val):
|
||||
warn(msg.format(what="datetime adapter"), DeprecationWarning, stacklevel=2)
|
||||
return val.isoformat(" ")
|
||||
|
||||
def convert_date(val):
|
||||
warn(msg.format(what="date converter"), DeprecationWarning, stacklevel=2)
|
||||
return datetime.date(*map(int, val.split(b"-")))
|
||||
|
||||
def convert_timestamp(val):
|
||||
warn(msg.format(what="timestamp converter"), DeprecationWarning, stacklevel=2)
|
||||
datepart, timepart = val.split(b" ")
|
||||
year, month, day = map(int, datepart.split(b"-"))
|
||||
timepart_full = timepart.split(b".")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue