MySQL and Python Select Statement -
i'm trying select specific text cell within table, can't mysql obey command. i'm sure i'm doing wrong, me feels right... i've checked documentation , google wasn't able come answer myself, hence why i'm turning you.
this outlay of mysql:
mysql> describe configuration; +---------+--------------+------+-----+---------+-------+ | field | type | null | key | default | | +---------+--------------+------+-----+---------+-------+ | option | varchar(255) | no | pri | null | | | setting | varchar(255) | no | | null | | +---------+--------------+------+-----+---------+-------+
in phpmyadmin looks this:
+---------+---------+ | option | setting | +---------+---------+ | version | 0.7.48 | +---------+---------+
i'm trying this:
#!/usr/bin/env python import mysqldb db = mysqldb.connect(host="xxx", user="xxx", passwd="xxx", db="xx") cur = db.cursor() cur.execute("select setting configuration option = version") current_version = cur.fetchone() db.close() cur.close()
how come isn't working? i'm @ loss.
e4c5 , acw1668 right:
cur.execute("select setting configuration `option` = 'version'")
does trick.
Comments
Post a Comment