Connecting to SAP HANA via pyodbc, using libodbcHDB32.so driver on 32bit Ubuntu.
I'm trying to create a table from a subquery, which has some placeholders:
>>> cursor.execute('CREATE TABLE temporary_table AS (SELECT ? AS a FROM DUMMY) WITH DATA', [1])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.ProgrammingError: ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000')
My query clearly has a single placeholder, and I'm passing a single value for this single placeholder.
If I change my query to a simple select from a subquery instead of a CREATE TABLE, it works fine:
>>> cursor.execute('SELECT * FROM (SELECT ? AS a FROM DUMMY) AS sub', [1])
<pyodbc.Cursor object at 0xb70f0b80>
If I change my query to select a constant value instead of a value passed via a placeholder, it also works fine:
>>> cursor.execute('CREATE TABLE temporary_table AS (SELECT 1 AS a FROM DUMMY) WITH DATA')
<pyodbc.Cursor object at 0xb71bcb80>
The only scenario that fails is a CREATE TABLE query with placeholders. I'm completely baffled and I have no idea what else to try. I need to create temporary tables with data from selects that need values passed via placeholders.
Any help would be appreciated.