bdarnell / torndb

A lightweight wrapper around MySQLdb. Originally part of the Tornado framework.
582 stars 202 forks source link

get wrong answer using torndb.get api #16

Closed baiyang closed 11 years ago

baiyang commented 11 years ago

my table's description below +---------------+-------------+------+-----+-------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------------+-------------+------+-----+-------------------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | hash_info | varchar(45) | NO | UNI | NULL | | | found_torrent | int(11) | YES | | 0 | | | found_time | timestamp | NO | | CURRENT_TIMESTAMP | | +---------------+-------------+------+-----+-------------------+----------------+

My sql command is select count(*) as t from t_hash_info where date(found_time) = "2013-11-19";

I execute the same sql command both in mysql and with torndb get api, get different result. At the same time, I do again using MySQLdb original api, get right answer. I dont know why.

baiyang commented 11 years ago

This happens if you set wrong time_zone. My Location is china, but torndb set time_zone = "0:00". After set time_zone "+8:00", It return right answer.

ishare commented 10 years ago

thx, I meet the same problem. and here is the init method:

def init(self, host, database, user=None, password=None, max_idle_time=7 * 3600, connect_timeout=0, time_zone="+0:00", charset = "utf8", sql_mode="TRADITIONAL"):

oczkers commented 10 years ago

What's Your timezone in os? Is it +0:00?