Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with table names containing character '%', related issue #87 #193

Open
wants to merge 1 commit into
base: azure-2.1
Choose a base branch
from

Conversation

atocyo
Copy link

@atocyo atocyo commented Feb 10, 2019

pyodbc uses '?' instead of '%s' as parameter placeholder.
SQL identifiers (consequently table names, columns) can contain special characters if surrounded by brackets '[...]'
Replace only those placeholders:'%, %%, %s, %d etc.' which are not surrounded by brackets.
This is not complete solution, there may be problems with string literals in SQL etc. , if non string placeholder is found (example:%d) there should be error raised.

Test:
input:
''', test,%ss, [Company$Item].[Percentile %], [Company$Item],%s, [bfbfdb%vbddfb], %, %% [[%]], [%'''
result:
''', test,?s, [Company$Item].[Percentile %], [Company$Item],?, [bfbfdb%vbddfb], ?, ? [[%]], [%'''

pyodbc uses '?' instead of '%s' as parameter placeholder.
SQL identifiers (consequently table names, columns) can contain special characters if surrounded by brackets '[...]'
Replace only those placeholders:'%, %%, %s, %d etc.' which are not surrounded by brackets.            
This is not complete solution, there may be problems with string literals in SQL etc. , if non string placeholder is found (example:%d) there should be error raised.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant