vendredi 22 mai 2015

Query sqlite table from python 3 includs brackets when querying one attribute, and not when querying many

I'm new to Phyton, using Python 3 I am trying to query a sqlite database. However if I query only one attribute the result incluces brackets - which I don't want. When doing similar query on two attributes, the brackets don't show.

Example, querying 2 attributes:

for row in c.execute("SELECT Employee_fname, Employee_lname FROM employee"):
        Employee_fname, Employee_lname = row
        print(Employee_fname, Employee_lname)

results in:

Amanda Anderson
Benny Baldrick
Charles Charlsson
David Davidson

Example, querying 1 attribute (removing Employee_lname from the query) :

for row in c.execute("SELECT Employee_fname FROM employee"):
        Employee_fname = row
        print(Employee_fname)

results in:

('Amanda',)
('Benny',)
('Charles',)
('David',)

Anyone knows what I'm doing wrong here?

Thanks

Aucun commentaire:

Enregistrer un commentaire