sqlalchemy および sqlite で %s 構文を使用しようとすると、エラーが発生します。postgresql と同じ構文で問題なく動作します。
import sqlalchemy
e = sqlalchemy.create_engine('sqlite:////tmp/x.db?timeout=120000')
e.execute('select * from people where name = %s;', 'joe').fetchall()
私はこれを得る:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1396, in _cursor_execute
context)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/default.py", line 301, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: near "%": syntax error
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1790, in execute
return connection.execute(statement, *multiparams, **params)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1191, in execute
params)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1287, in _execute_text
return self.__execute_context(context)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1302, in __execute_context
context.parameters[0], context=context)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1403, in _cursor_execute
context)
File "/usr/lib/python3/dist-packages/sqlalchemy/engine/base.py", line 1360, in _handle_dbapi_exception
from e
sqlalchemy.exc.OperationalError: (OperationalError) near "%": syntax error 'select * from people where name = %s;' ('joe',)
>>>
繰り返しますが、postgres とまったく同じことがリストまたは行を返します。これはバグですか?それとも期待されていますか?