Django Integerfield Returning Long
I am wondering why, when I get a field from db which is defined as models.IntegerField in models.py I am getting long instead of int e.g. I have a model EventSchedule class EventSc
Solution 1:
this is probably a side effect of the underlying dbapi
handler, which returns long
for most everything:
>>>import MySQLdb>>>db=MySQLdb.connect(db="test")>>>c = db.cursor()>>>c.execute("Select 1")
1L
The difference for most uses is cosmetic. There are subtle differences from one driver to another, for instance sqlite3
does not return long for this same query:
>>>import sqlite3>>>db = sqlite3.connect(":memory:")>>>c = db.cursor()>>>c.execute("Select 1")
<sqlite3.Cursor object at 0x7f2c425ae9d0>
>>>c.execute("Select 1").fetchone()
(1,)
Post a Comment for "Django Integerfield Returning Long"