python + database book
new to python. i work with db heavily. any good book for python + database? -- http://mail.python.org/mailman/listinfo/python-list
db.commit() to take effect
I was testing the python+mysql
here are my sample codes:
import MySQLdb
from pprint import pprint
db = MySQLdb.connect(host="localhost", user="root", passwd="password",
db="database")
cursor = db.cursor()
cursor.execute('update promo set date=100")
i was expecting the cursor.execute will update my db immediately.
it wasn't. not until i run db.commit(), then only i see the value
changes.
it that the right way to update db?
--
http://mail.python.org/mailman/listinfo/python-list
cursor.executemany() float error
Data Struct:
from (string), to (string), rate (float)
when i run this:
cursor.executemany('insert into promo (`From`,`To`, `RATE`) \
values (%s,%s,%f)', [ ('AA','BB',10.2), ('CC','DD',10.3) ] )
i got this error:
TypeError: float argument required
i checked, 10.2 & 10.3 , there are at the right loc.
what went wrong??
--
http://mail.python.org/mailman/listinfo/python-list
Re: cursor.executemany() float error
i am using mysql
i tried the
cursor.executemany('insert into promo (`From`,`To`, `RATE`) \
values (%s,%s,%s)', [ ('AA','BB',10.2), ('CC','DD',10.3) ] )
and it works.
very strange. isn't it?
Fredrik Lundh wrote:
> progman wrote:
>
> > cursor.executemany('insert into promo (`From`,`To`, `RATE`) \
> > values (%s,%s,%f)', [ ('AA','BB',10.2), ('CC','DD',10.3) ] )
> >
> > i got this error:
> > TypeError: float argument required
> >
> > i checked, 10.2 & 10.3 , there are at the right loc.
> > what went wrong??
>
> posting a bit more of the traceback, and mentioning what database you're
> using might be helpful.
>
> have you tried using "%s" markers for all parameters, btw? (SQL data
> binding and %-style string formatting are two different things, after all).
>
>
--
http://mail.python.org/mailman/listinfo/python-list
RAD for python
is there a VB-alike tool for python to create forms?? -- http://mail.python.org/mailman/listinfo/python-list
