homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: sqlite3 module ignores placeholders in CREATE TRIGGER code
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: ghaering Nosy List: BreamoreBoy, Christian.Schilling, GuGu, flupke, ghaering, mrabarnett
Priority: normal Keywords:

Created on 2012年02月21日 19:39 by GuGu, last changed 2022年04月11日 14:57 by admin. This issue is now closed.

Messages (4)
msg153896 - (view) Author: GuGu (GuGu) Date: 2012年02月21日 19:39
When I try to use placeholders in CREATE TRIGGER (for django-denorm module) SQLite module just ignores placeholders and sends `None` to it.
For example:
 In [11]: c.cursor().execute('CREATE TRIGGER test1 after insert on a for each row begin UPDATE a SET b=?; END', '1').fetchone()
 In [12]: c.cursor().execute('INSERT INTO a values (100)')
 Out[12]: <pysqlite2.dbapi2.Cursor at 0x101d77e30>
 In [13]: c.cursor().execute('SELECT * FROM a').fetchall()
 Out[13]: [(None,), (None,), (None,)]
 In [14]: c.cursor().execute('DROP TRIGGER test1')
 Out[14]: <pysqlite2.dbapi2.Cursor at 0x101d77f10>
 In [15]: c.cursor().execute('CREATE TRIGGER test1 after insert on a for each row begin UPDATE a SET b=1; END').fetchone()
 In [16]: c.cursor().execute('INSERT INTO a values (100)')
 Out[16]: <pysqlite2.dbapi2.Cursor at 0x101d77f80>
 In [17]: c.cursor().execute('SELECT * FROM a').fetchall()
 Out[17]: [(u'1',), (u'1',), (u'1',), (u'1',)]
In MySQLdb and psycopg2 creating triggers with a placeholder works.
msg222179 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014年07月03日 13:59
Can we have a reply to this please as I don't understand enough about sqlite3 to comment.
msg226638 - (view) Author: Matthew Barnett (mrabarnett) * (Python triager) Date: 2014年09月09日 15:21
For comparison:
Python 3.1.3:
[(b'',)]
Python 3.2.5:
[(None,)]
Python 3.3.5:
[(b'',)]
Python 3.4.1:
sqlite3.OperationalError: trigger cannot use variables
msg233387 - (view) Author: Gerhard Häring (ghaering) * (Python committer) Date: 2015年01月04日 03:24
The sqlite3 module is not at fault here. If it does not work, then is is a restriction of SQLite3 - at which places it accepts bind parameters.
This closing as "not a bug".
History
Date User Action Args
2022年04月11日 14:57:27adminsetgithub: 58284
2015年01月04日 03:24:17ghaeringsetstatus: open -> closed
assignee: ghaering
resolution: not a bug
messages: + msg233387
2014年09月09日 15:21:58mrabarnettsetnosy: + mrabarnett
messages: + msg226638
2014年09月08日 12:57:29flupkesetnosy: + flupke
2014年07月03日 13:59:22BreamoreBoysetnosy: + BreamoreBoy

messages: + msg222179
title: sqlite3 module ignores placeholers in CREATE TRIGGER code -> sqlite3 module ignores placeholders in CREATE TRIGGER code
2012年02月25日 08:55:21Christian.Schillingsetnosy: + Christian.Schilling
2012年02月25日 00:37:03terry.reedysetnosy: + ghaering
2012年02月21日 19:39:32GuGucreate

AltStyle によって変換されたページ (->オリジナル) /