File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -1336,29 +1336,30 @@ timestamp converter.
13361336Adapter and Converter Recipes
13371337-----------------------------
13381338
1339- This section shows recipes for common adapters and converters.
1339+ This section shows recipes for timezone-naive adapters and converters.
13401340
13411341.. testcode ::
13421342
13431343 import sqlite3
13441344
1345- # Timezone-naive datetime adapters and converters.
13461345 def adapt_date(val):
13471346 return val.isoformat()
13481347
13491348 def adapt_datetime(val):
13501349 return val.isoformat(" ")
13511350
13521351 def convert_date(val):
1352+ import datetime
13531353 return datetime.date(*map(int, val.split(b"-")))
13541354
13551355 def convert_timestamp(val):
1356+ import datetime
13561357 datepart, timepart = val.split(b" ")
13571358 year, month, day = map(int, datepart.split(b"-"))
13581359 timepart_full = timepart.split(b".")
13591360 hours, minutes, seconds = map(int, timepart_full[0].split(b":"))
13601361 if len(timepart_full) == 2:
1361- microseconds = int(' {:0<6.6}' .format(timepart_full[1].decode()))
1362+ microseconds = int(" {:0<6.6}" .format(timepart_full[1].decode()))
13621363 else:
13631364 microseconds = 0
13641365
You can’t perform that action at this time.
0 commit comments