Re: [pysqlite] Substituted arguments showing as tuples

ggivler-l/kJKU/bHgBWk0Htik3J/[email protected] Mon, 4 Aug 2008 22:31:03 -0400
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <OF98B16EC3.5C43D173-ON8525749C.000D054C-8525749C.000DD433@bankofny.com>
A fetchall() returns a list of tuples, so to get just the value you do 
colors[0][0] since you are only asking for one value in your queriy. If 
you do a fetchone() you will get a tuple, and can just do colors[0] to get 
the value if I remember correclty. SInce fetchone() returns just a tuple

Thanks,

Greg Givler
Information Technology
Pershing Managed Accounts Solutions
10 Valley Stream Parkway
Malvern, PA 19355
Phone: (484) 605-4826
Email: ggivler-l/kJKU/bHgBWk0Htik3J/[email protected]



"Milo Pschigoda" <[email protected]> 
Sent by: list-pysqlite-bounces-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org
08/04/2008 07:51 PM
Please respond to
"About pysqlite and APSW." <list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org>


To
list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org
cc

Subject
[pysqlite] Substituted arguments showing as tuples






I'm trying to use sqlite's argument substituition, but I'm having 
problems:

cur.execute("create table color (id integer primary key,color string)")

cur.execute("insert into color values(null,?)",('other',))
cur.execute("insert into color values(null,?)",('multi/patterned',))
cur.execute("insert into color values(null,?)",('white',))

is what I have currently, but when I pull the information out with this 
code

colors=cur.execute("select color from color").fetchall()
print "Colors:"
print colors
print type(colors[0])

I get this output:

Colors:
[(u'other',), (u'multi/patterned',), (u'white',), (u'black',),
(u'natural',), (u'red',), (u'green',), (u'blue',)]
<type 'tuple'>

I even tried this line:
cur.execute("insert into color values(?,?)",(1,'other'))
with the same <type 'tuple'> result.  I can work around this problem,
but I feel I shouldn't have to, I don't remember ever having to
before.  What am I doing wrong here?
_______________________________________________
list-pysqlite mailing list
list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org
http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please call the help desk at ext 4850
______________________________________________________________________



******************************************************
IMPORTANT: Any information contained in this communication is intended for the use of the named individual or entity. All information contained in this communication is not intended or construed as an offer, solicitation, or a recommendation to purchase any security. Advice, suggestions or views presented in this communication are not necessarily those of Pershing LLC nor do they warrant a complete or accurate statement. 

If you are not an intended party to this communication, please notify the sender and delete/destroy any and all copies of this communication. Unintended recipients shall not review, reproduce, disseminate nor disclose any information contained in this communication. Pershing LLC reserves the right to monitor and retain all incoming and outgoing communications as permitted by applicable law.

Email communications may contain viruses or other defects. Pershing LLC does not accept liability nor does it warrant that email communications are virus or defect free.
******************************************************

_______________________________________________
list-pysqlite mailing list
list-pysqlite-FR6EJeJVuqdwc357pe9rcyQmJico6nz3epZhswDD4dQ@public.gmane.org
http://itsystementwicklung.de/cgi-bin/mailman/listinfo/list-pysqlite