pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied. The current statement uses

Discussion in 'Python' started by F. GEIGER, May 17, 2005.

  1. F. GEIGER

    F. GEIGER Guest

    Im on Python 2.3.4, using pysqlite 2.0.0 (final).

    When I try to execute

    self._dbc.execute(q, data)

    where q is 'select count(*) from Difflets ' and date is None

    I get the following exception:

    pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied.
    The current statement uses 0, and there are -1 supplied.

    Any ideas?

    Many thanks in advance and kind regards
    Franz GEIGER
     
    F. GEIGER, May 17, 2005
    #1
    1. Advertising

  2. F. GEIGER

    F. GEIGER Guest

    Arrgh, sorry for that post!

    self._dbc.execute(q, data)

    where data is None, works with MySQL. For SQLite I have to write

    if data is not None:
    self._dbc.execute(q, data)
    else:
    self._dbc.execute(q)

    Sorry again,
    Franz GEIGER



    "F. GEIGER" <> schrieb im Newsbeitrag
    news:d6dfi8$ck8$...
    > Im on Python 2.3.4, using pysqlite 2.0.0 (final).
    >
    > When I try to execute
    >
    > self._dbc.execute(q, data)
    >
    > where q is 'select count(*) from Difflets ' and date is None
    >
    > I get the following exception:
    >
    > pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindings supplied.
    > The current statement uses 0, and there are -1 supplied.
    >
    > Any ideas?
    >
    > Many thanks in advance and kind regards
    > Franz GEIGER
    >
    >
    >
     
    F. GEIGER, May 17, 2005
    #2
    1. Advertising

  3. Re: pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindingssupplied. The current statement uses 0, and there are -1 supplied.

    F. GEIGER wrote:
    > Arrgh, sorry for that post!
    >
    > self._dbc.execute(q, data)
    >
    > where data is None, works with MySQL. For SQLite I have to write
    >
    > if data is not None:
    > self._dbc.execute(q, data)
    > else:
    > self._dbc.execute(q)


    No, you have to write:

    self._dbc.execute(q, (data,))

    in both drivers.

    i. e. the second parameter to execute *must* be a sequence. Some drivers
    (maybe MySQLdb, too) automatically correct the wrong call and transform a:

    execute(sql, single_param)

    into a

    execute(sql, (single_param,))

    for you if they notice that "!PySequence_Check(single_param)".

    pysqlite 2 does not do this.

    HTH,

    -- Gerhard
     
    =?ISO-8859-1?Q?Gerhard_H=E4ring?=, May 17, 2005
    #3
  4. F. GEIGER

    F. GEIGER Guest

    Re: pysqlite2.dbapi2.ProgrammingError: Incorrect number of bindingssupplied. The current statement uses 0, and there are -1 supplied.

    Thank you Gerhard,

    "Gerhard Häring" <> schrieb im Newsbeitrag
    news:...
    > F. GEIGER wrote:
    > > Arrgh, sorry for that post!
    > >
    > > self._dbc.execute(q, data)
    > >
    > > where data is None, works with MySQL. For SQLite I have to write
    > >
    > > if data is not None:
    > > self._dbc.execute(q, data)
    > > else:
    > > self._dbc.execute(q)

    >
    > No, you have to write:
    >
    > self._dbc.execute(q, (data,))
    >
    > in both drivers.
    >
    > i. e. the second parameter to execute *must* be a sequence. Some drivers
    > (maybe MySQLdb, too) automatically correct the wrong call and transform a:
    >


    Okay, that makes sense.


    > execute(sql, single_param)
    >
    > into a
    >
    > execute(sql, (single_param,))
    >
    > for you if they notice that "!PySequence_Check(single_param)".
    >
    > pysqlite 2 does not do this.
    >
    > HTH,
    >
    > -- Gerhard


    Many thanks again
    Franz
     
    F. GEIGER, May 18, 2005
    #4
    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. F. GEIGER
    Replies:
    1
    Views:
    645
    Gerhard Haering
    May 19, 2005
  2. Gabriel Rossetti
    Replies:
    4
    Views:
    1,455
    John Machin
    Jun 17, 2009
  3. Gerhard Häring
    Replies:
    2
    Views:
    1,062
    Gerhard Häring
    Jun 20, 2009
  4. Replies:
    1
    Views:
    363
    Gerhard Häring
    Nov 30, 2009
  5. nepaul
    Replies:
    2
    Views:
    276
    Peter Otten
    Aug 17, 2012
Loading...

Share This Page