Skip to content
Draft
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions python/postgresql/postgresql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ limitations under the License.
dbc install postgresql
```

2. Customize the Python script `main.py` as needed
- Change the connection arguments in `db_kwargs`
2. Customize the connection profile `profile.toml` and the script `main.py` as needed
- Change the connection arguments in `profile.toml`
- Format `uri` according to the [connection URI format used by PostgreSQL](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING-URIS), or keep it as is to use the data included with this example
- If you changed which database you're connecting to, also change the SQL SELECT statement in `cursor.execute()`
- If you changed which database you're connecting to, also change the SQL SELECT statement in `cursor.execute()` in `main.py`

3. Run the Python script:

Expand Down
9 changes: 5 additions & 4 deletions python/postgresql/postgresql/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
from adbc_driver_manager import dbapi

with (
dbapi.connect(
driver="postgresql",
db_kwargs={"uri": "postgresql://postgres:mysecretpassword@localhost:5432/demo"},
) as con,
dbapi.connect(profile="./profile.toml") as con,
# or: dbapi.connect(uri="profile://./profile.toml")
# or: move `profile.toml` to the profile search location as documented at
# https://arrow.apache.org/adbc/main/format/connection_profiles.html#profile-search-locations
# and specify `profile="profile"` or `uri="profile://profile"`
con.cursor() as cursor,
):
cursor.execute("SELECT * FROM games;")
Expand Down
5 changes: 5 additions & 0 deletions python/postgresql/postgresql/profile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version = 1
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After apache/arrow-adbc#4083 is merged:

Suggested change
version = 1
profile_version = 1

driver = "postgresql"

[options]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After apache/arrow-adbc#4083 is merged:

Suggested change
[options]
[Options]

uri = "postgresql://postgres:mysecretpassword@localhost:5432/demo"