cursor.executemany() float error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • progman

    #1

    cursor.executemany() float error

    Data Struct:
    from (string), to (string), rate (float)

    when i run this:

    cursor.executem any('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??

  • Fredrik Lundh

    #2
    Re: cursor.executem any() float error

    progman wrote:
    cursor.executem any('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>

    Comment

    • progman

      #3
      Re: cursor.executem any() float error

      i am using mysql

      i tried the
      cursor.executem any('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.executem any('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>

      Comment

      Working...