On Sat, Dec 12, 2009 at 5:11 PM, Carsten Haese <carsten.ha...@gmail.com>wrote:

> Victor Subervi wrote:
> > Hi;
> > What type does python consider a MySQL Set??
>
> Let's take a look:
>
> >>> import MySQLdb
> >>> conn = MySQLdb.connect(db="carsten", user="blah", passwd="blah")
> >>> cur = conn.cursor()
> >>> cur.execute("""
> ...     create table pizza (
> ...         id integer,
> ...         toppings set('cheese','sauce','peperoni','mushrooms')
> ...     )
> ... """)
> 0L
> >>> cur.execute("""
> ...     insert into pizza values(1, 'cheese,sauce,peperoni')
> ... """)
> 1L
> >>> cur.execute("select * from pizza")
> 1L
> >>> rows = cur.fetchall()
> >>> toppings = rows[0][1]
> >>> print toppings
> cheese,sauce,peperoni
> >>> print type(toppings)
> <type 'str'>
>
>
> Looks like a string to me.
>

Yep, sure does, but it isn't. Again:

              if isinstance(colValue[0], (str, int, long, float, long,
complex, unicode, list, buffer, xrange, tuple)):
                pass
              else:
                print 'XXX'

and those "strings" printed triple-X. It ain't no string. Besides, if it
were a string, I'd be able to slice it, wouldn't I? Can't slice it either.
V
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to