1

I'm getting the following error while running my sql in python

/usr/lib/python2.6/site-packages/django/db/backends/mysql/base.py:64: RuntimeWarning: SQLite received a naive datetime (2012-06-22 15:53:43) while time zone support is active.

my query also returns the wrong data. if i change the time up 2 hours (17:53:43 instead of 15:53:43), my timezone atm is gmt +2 so i think the problem is in the time zone.

how do i change my query to make the sql execute in the way i intend it to?

sql:

sqlQuery = """SELECT w.id, w.serial, w.finishdate, w.weighingtype_id, w.netto, w.bruto, w.deleted
    FROM weighing w
    LEFT JOIN weighing w1
    ON w1.id = w.parent_id 
    WHERE w.user_id = %(userid)s"""
if date:
    sqlQuery = sqlQuery + " AND (w.created = %(date)s OR w.modified > %(date)s)"

edit: added my code for transforming the datetime

data = request.GET.copy()
if 'date' in data:
    try:
        data['date'] = datetime.datetime.strptime(data['date'], "%Y-%m-%dT%H:%M:%S")
    except:
        raise error(311)
Arno_C
  • 109
  • 3
  • 7

0 Answers0