What's "connection"? Is it django.db.connection?
What're your settings? DATABASE_* and DEBUG are relevant here.
> What're your settings? DATABASE_* and DEBUG are relevant here.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
DATABASE_ENGINE = 'mysql' # 'postgresql_psycopg2', 'postgresql',
'mysql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = 'test' # Or path to database file if using
sqlite3.
DATABASE_USER = 'root' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = 'localhost' # Set to empty string for
localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.
It works for the ORM :)
I'm not quite sure what you're saying here. Are you saying it returns
the string "LONG", or that it returns something that has Python type
'long' -- such as 1L, rather than 1? In the latter case, there's no
problem at all here. A long is just a number. Just use it as you
normally would. MySQL always returns longs (for historical reasons, due
to the need for explicit conversions between Python ints and longs in
older Python versions).
Regards,
Malcolm
--
Works better when plugged in.
http://www.pointy-stick.com/blog/
So I have a function in views:
#################################
def getEntries(user):
"""Returns unique entries and page views for each of last 30 day
"""
cursor = connection.cursor ()
query = cursor.execute('SELECT COUNT(DISTINCT(ip)) AS uniqs,
COUNT(ip) AS views, date FROM pw_logs GROUP BY date LIMIT 30')
return query.fetchall()
#################################
Return values are not defined.
thanks, that did the job :)
Why not? You haven't explained why this is an error. If you think the
type is a problem, you're mistaken: a long is just a number. If you
think the fact that it's returning a number is wrong, that's also a bad
assumption: PEP 249 says that execute() can return whatever it likes.
Karen has pointed out a workaround, but there really isn't any bug here.
Regards,
Malcolm
--
How many of you believe in telekinesis? Raise my hand...
http://www.pointy-stick.com/blog/