Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread Danny Yoo
On Tue, May 10, 2016 at 10:37 PM, nitin chandra wrote: > Thank you Danny, Alan, > > @ Danny > > I added 'str(formt(line1[0]))' will this do ? Unfortunately, I don't know: what makes me hesitant is the following: * The above is doing something just to line1[0], which looks odd. Why just li

Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread nitin chandra
Thank you Danny, Alan, @ Danny I added 'str(formt(line1[0]))' will this do ? @ Alan I did just that nextRow[0] Triple quotes .. there is some part of code in multi-line so... me being just lazyyy ... copy pasted / edited ... and left what is working . just my excuse :P

Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread Alan Gauld via Tutor
On 10/05/16 08:33, nitin chandra wrote: > here is the result. > > 1 > ('Supervisor',) > > 1 > Vinayak > Salunke > 1 > > Now I need to remove the braces and quotes .. :) No you don't. Those are just part of the string representation that Python uses when printing a string inside a tuple. If yo

Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread Danny Yoo
> here is the result. > > 1 > ('Supervisor',) > > 1 > Vinayak > Salunke > 1 > > Now I need to remove the braces and quotes .. :) By the way, be very careful about generating HTML via naive string concatenation. If you can use a template engine such as Jinja (http://jinja.pocoo.org/), please do

Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread nitin chandra
IT WORKED THANK YOU SSS MUCH ...phew .. Thank you here is the result. 1 ('Supervisor',) 1 Vinayak Salunke 1 Now I need to remove the braces and quotes .. :) Thank you Nitin On 10 May 2016 at 12:30, Peter Otten <__pete...@web.de> wrote: > nitin chandra wrote: > >> Thanks Alan, Peter

Re: [Tutor] postgreSQL + psycopg2

2016-05-10 Thread Peter Otten
nitin chandra wrote: > Thanks Alan, Peter > > but didn't work > > nextrow=(cursor1.execute(query, (design1,))).fetchone() > AttributeError: 'NoneType' object has no attribute 'fetchone' Try without the method chaining: cursor1.execute(query, (design1,)) nextrow = cursor1.fetchone() __

Re: [Tutor] postgreSQL + psycopg2

2016-05-09 Thread nitin chandra
Thanks Alan, Peter but didn't work nextrow=(cursor1.execute(query, (design1,))).fetchone() AttributeError: 'NoneType' object has no attribute 'fetchone' 1. Yes Alan, the variable 'design1' has a value '1'. This is how I tested it from python command : >>> import psycopg2 >>> import datetim

Re: [Tutor] postgreSQL + psycopg2

2016-05-09 Thread Alan Gauld via Tutor
On 09/05/16 22:14, nitin chandra wrote: > 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 "" > for row in line1: >

Re: [Tutor] postgreSQL + psycopg2

2016-05-09 Thread Peter Otten
nitin chandra wrote: > 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)) Note that in

[Tutor] postgreSQL + psycopg2

2016-05-09 Thread nitin chandra
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 "" for row in lin