cursor.executemany() float error

Discussion in 'Python' started by progman, Dec 3, 2006.

  1. progman

    progman Guest

    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??
    progman, Dec 3, 2006
    #1
    1. Advertising

  2. 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).

    </F>
    Fredrik Lundh, Dec 3, 2006
    #2
    1. Advertising

  3. progman

    progman Guest

    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).
    >
    > </F>
    progman, Dec 3, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bd
    Replies:
    0
    Views:
    605
  2. Daniel Bowett

    MySQLdb executemany

    Daniel Bowett, Jan 26, 2005, in forum: Python
    Replies:
    0
    Views:
    546
    Daniel Bowett
    Jan 26, 2005
  3. invy
    Replies:
    4
    Views:
    379
    CBFalconer
    Dec 28, 2006
  4. Carsten Fuchs
    Replies:
    45
    Views:
    1,507
    James Kanze
    Oct 8, 2009
  5. dmaziuk
    Replies:
    3
    Views:
    553
    Chris Gonnerman
    Jan 25, 2011
Loading...

Share This Page