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

docs(python): add a note to the read_database_uri docstring about escaping special characters in the connection string #13514

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions py-polars/polars/io/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,10 @@ def read_database_uri(
* "postgresql://user:pass@server:port/database"
* "snowflake://user:pass@account/database/schema?warehouse=warehouse&role=role"
The caller is responsible for escaping any special characters in the string,
which will be passed "as-is" to the underlying engine (this is most often
required when coming across special characters in the password).
partition_on
The column on which to partition the result (connectorx).
partition_range
Expand Down Expand Up @@ -651,6 +655,15 @@ def read_database_uri(
For `adbc` you will need to have installed `pyarrow` and the ADBC driver associated
with the backend you are connecting to, eg: `adbc-driver-postgresql`.
If your password contains special characters, you will need to escape them.
This will usually require the use of a URL-escaping function, for example:
>>> from urllib.parse import quote, quote_plus
>>> quote_plus("pass word?")
'pass+word%3F'
>>> quote("pass word?")
'pass%20word%3F'
See Also
--------
read_database : Create a DataFrame from a SQL query using a connection object.
Expand Down