Closed ThanKarab closed 2 years ago
This doesn't seem to be a problem with complex tables, it's the same problem with normal tables as well.
For example:
cur.execute("select * from %s", parameters="tables")
Returns:
pymonetdb.exceptions.OperationalError: 42000!syntax error, unexpected STRING in: "select * from 'tables'"
Hi @ThanKarab , I think you are missusing this feature. You should only use placeholders for literals. As a work arround you can do something like this:
cur.execute("select * from \"{0}\"".format("test-table"))
but this is not advisable or something that we expect users to do.
Hello @lrpereira , thanks for the reply!
I am not using string literals, that was only for demonstrating the problem.
Yes, exactly. In both examples you provided, you're trying to use a placeholder for a table identifier and that is not allowed. The intent here follows SQL prepared statement link. Also, for the first example, you need to properly escape that identifier due to the special char "-". If you try this on mclient session, you'll find the same result. Hope this clarifies the issue.
Ok, now I understand. Thanks a lot and sorry for my confusion.
Hello, I have bumped into a problem where I create a table that contains a '-'. For example:
CREATE TABLE "test-table" (test INT);
Then I try to get all it's data through the pymonetdb interface using parameters:
cur.execute("select * from %s;", parameters="test-table")
Actual response:
pymonetdb.exceptions.OperationalError: 42000!syntax error, unexpected STRING in: "select * from 'test-table'"
Expected response: I would expect it to execute the query by putting the
test-table
name into double quotes instead of single quotes.