tags:

views:

17

answers:

2

Good people, I have installed djangoratings in my django project and i want to select records directly using raw sql from the djangoratings tables, i have followed the instruction given here but nothing seems to work.

My code looks like this;

def InsertRecord():
    from django.db import connection, transaction
    cursor = connection.cursor()

    cursor.execute(" Select ip_address from djangoratings_vote where id=%d ",[3])
    row = cursor.fetchone()
    print row   # row has None at this point

The function does not select the row, despite it exists in the table. Am using , django 1.2.1, sqlite3

What am i not doing?

gath

+1  A: 

I think only strings will work, so replace %d with %s and it should work

cursor.execute(" Select ip_address from djangoratings_vote where id=%s ",[3,])
Jann
A: 

good people,

Sorry i saw where the mistake was,

On the sql string, the formating place holder should be "%s" and not "%d"

thanks

gath