Commit bffb4913 authored by Julian Rother's avatar Julian Rother
Browse files

Strip microseconds in query parameters

parent 7b01c4e7
from server import *
import sqlite3
import re
import datetime
if config['DB_ENGINE'] == 'sqlite':
created = not os.path.exists(config['SQLITE_DB'])
......@@ -31,11 +30,7 @@ def convert_timestamp(val):
year, month, day = map(int, datepart.split(b"-"))
timepart_full = timepart.split(b".")
hours, minutes, seconds = map(int, timepart_full[0].split(b":"))
if len(timepart_full) == 2:
microseconds = int('{:0<6.6}'.format(timepart_full[1].decode()))
microseconds = 0
val = datetime.datetime(year, month, day, hours, minutes, seconds, microseconds)
val = datetime(year, month, day, hours, minutes, seconds, 0)
except ValueError:
val = None
return val
......@@ -44,6 +39,12 @@ sqlite3.register_converter('datetime', convert_timestamp)
sqlite3.register_converter('timestamp', convert_timestamp)
def query(operation, *params):
_params = []
for p in params:
if isinstance(p, datetime):
p = p.replace(microsecond=0)
params = _params
if config['DB_ENGINE'] == 'mysql':
import mysql.connector
if 'db' not in g or not g.db.is_connected():
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment