-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
read_sql should accept a sql_params parameter #10899
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
Comments
Is it that what you are looking for? |
That's probably the parameter to use but I think we should warm more in doc
raises
but
again raises
|
I think doc should (at least) provide a SQL query with a Maybe after http://pandas-docs.github.io/pandas-docs-travis/io.html#querying
and before chunks I wonder if there isn't a way to disable multiple statements. |
I try this:
it raises
and So I think the problem is on (mysqlconnector) driver side. |
@scls19fr Improvement to the docs are certainly welcome! The warning you see above is actually a warning (feature) from sqlite3 itself (the have It is always possible to misuse |
In fact the problem is on driver side because Pandas seems not to allow by default several statements. I think that doc should be improve with the use of see #10846 |
This PR #10983 shows that
maybe doc http://pandas-docs.github.io/pandas-docs-travis/io.html#id4 should be improved accordingly After "
" maybe a query with parameters should be shown
|
But what is odd, is that I can't do
table name can't be a parameter. Why ? Maybe @stephenpascoe can help |
AFAIK this would depend on the SQL backend. SQLAlchemy passes the unsubstituted SQL expression and the parameter dictionary to the underlying DB API to interpret. It would be reasonable for a DB API not to support substitution of the table parameter as it could be an SQL injection vulnerability. Also it wouldn't necessarily be supported by the DB's stored procedure system. Personally, I've never tried this but a quick test with the raw sqlite3 db api shows a "?" in the table position gives a syntax error. |
Parameter substitution is not possible for the table name AFAIK. The thing is, in sql there is often a difference between string quoting, and variable quoting (see eg https://sqlite.org/lang_keywords.html the difference in quoting between string and identifier). So you are filling in a string, which is for sql something else as a variable name (in this case a table name). @scls19fr if you want to add that example to the docs, always welcome! |
Hello, I find this issue is quite interesting. I've created a PR to add some examples (including the bad examples and good examples) to the docs. Comments are appreciated. |
take |
Is this issue fully resolved by #56546? Or are there any remaining tasks? |
Hello,
I wonder if current use of
read_sql
couldn't lead to SQL injection.I read in https://docs.python.org/2/library/sqlite3.html
Most of people will use
(or
.format(...)
)with
read_sql
if
symbol
is an unsafe input it could lead some problemshttp://xkcd.com/327/
Is it safe to do it here ?
Kind regards
The text was updated successfully, but these errors were encountered: