[Tutor] postgreSQL + psycopg2

nitin chandra nitinchandra1 at gmail.com
Mon May 9 17:14:05 EDT 2016


Hi All,

I am trying to pass a variable to the following statement :

for line1 in smallLIST1:
    design1 = line1[3]
    print design1
    nextRow=cursor1.execute("SELECT designation_name FROM designation
WHERE designation_id = %s;", (design1))
    print nextRow
    print """<tr>"""
    for row in line1:
        print """<td>"""+str(row)+"""</td>"""
    print """</tr>"""

1st "print" shows values 1 , correctly.
2nd "print" shows "None".

I am not able to pass this value, 1, as variable to the SELECT statement.

the following is 'line1'

(1, 'Vinayak', 'Salunke', '1', datetime.date(1982, 6, 6), 9871234567L,
'Tower-1,Millinium tower', 0, 1, datetime.date(2016, 5, 6),
datetime.datetime(2016, 5, 6, 22, 55, 5,
tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=330, name=None)))


On postgreSQL command this works

SELECT designation_name FROM designation WHERE designation_id = 1;

Python 2.7.6, Postgresql 9.3.7, psycopg2, apache & cgi.

A little help.

Thanks

Nitin


More information about the Tutor mailing list