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.
1336
1336
Adapter and Converter Recipes
1337
1337
-----------------------------
1338
1338
1339
- This section shows recipes for common adapters and converters.
1339
+ This section shows recipes for timezone-naive adapters and converters.
1340
1340
1341
1341
.. testcode ::
1342
1342
1343
1343
import sqlite3
1344
1344
1345
- # Timezone-naive datetime adapters and converters.
1346
1345
def adapt_date(val):
1347
1346
return val.isoformat()
1348
1347
1349
1348
def adapt_datetime(val):
1350
1349
return val.isoformat(" ")
1351
1350
1352
1351
def convert_date(val):
1352
+ import datetime
1353
1353
return datetime.date(*map(int, val.split(b"-")))
1354
1354
1355
1355
def convert_timestamp(val):
1356
+ import datetime
1356
1357
datepart, timepart = val.split(b" ")
1357
1358
year, month, day = map(int, datepart.split(b"-"))
1358
1359
timepart_full = timepart.split(b".")
1359
1360
hours, minutes, seconds = map(int, timepart_full[0].split(b":"))
1360
1361
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()))
1362
1363
else:
1363
1364
microseconds = 0
1364
1365
You can’t perform that action at this time.
0 commit comments