Why isn't this query working in python?

erikcw erikwickstrom at gmail.com
Fri May 25 10:39:06 EDT 2007


Hi all,

I'm trying to run the following query:

amember_db = MySQLdb.connect(host="localhost", user="**********",
passwd="*****", db="*******")
            # create a cursor
            self.amember_cursor = amember_db.cursor()
            # execute SQL statement
            sql = """SELECT payment_id FROM amember_payments WHERE
member_id=%s AND expire_date > NOW() AND completed=1 AND (product_id
>11 AND product_id <21)""", (self.uid)
            print sql
            self.amember_cursor.execute(*sql)
            amember_result = self.cursor.fetchall()
            print amember_result

When I manually run the SQL query in mysql, I get a result, but for
some reason I get an empty result in python.  Here are some notes that
may be of importance.

-I have 2 connections open to MySQL in this script (they are both in
seperate objects of course)
- self.uid = 1972L
-print amember_result = ()

Any ideas?

Thanks!
Erik




More information about the Python-list mailing list