Skip to content

Commit fcc9e8c

Browse files
committed
Improve examples for connect_to_table()
1 parent 330f8be commit fcc9e8c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

pointblank/validate.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,27 +2149,27 @@ def connect_to_table(connection_string: str) -> Any:
21492149
--------
21502150
Connect to a DuckDB table:
21512151

2152-
```python
2152+
```{python}
21532153
import pointblank as pb
21542154

2155-
# Connect to a specific table
2156-
table = pb.connect_to_table("duckdb:///sales_data.ddb::quarterly_sales")
2155+
# Get path to a DuckDB database file from package data
2156+
duckdb_path = pb.get_data_path("game_revenue", "duckdb")
2157+
2158+
# Connect to the `game_revenue` table in the DuckDB database
2159+
game_revenue = pb.connect_to_table(f"duckdb:///{duckdb_path}::game_revenue")
21572160

2158-
# Use with validation
2159-
validation = pb.Validate(data=table).col_exists(["quarter", "revenue"]).interrogate()
2161+
# Use with the `preview()` function
2162+
pb.preview(game_revenue)
21602163
```
21612164

21622165
If you omit the table specification, you'll get helpful guidance:
21632166

2164-
```python
2165-
try:
2166-
table = pb.connect_to_table("duckdb:///sales_data.ddb")
2167-
except ValueError as e:
2168-
print(e)
2169-
# Output shows available tables and proper syntax
2167+
```{python}
2168+
#| error: true
2169+
pb.connect_to_table(f"duckdb:///{duckdb_path}")
21702170
```
21712171

2172-
Backend-specific connection examples:
2172+
Here are some backend-specific connection examples:
21732173

21742174
```python
21752175
# PostgreSQL
@@ -2187,9 +2187,11 @@ def connect_to_table(connection_string: str) -> Any:
21872187
This function requires the Ibis library with appropriate backend drivers:
21882188

21892189
```bash
2190+
# You can install a set of common backends:
21902191
pip install 'ibis-framework[duckdb,postgres,mysql,sqlite]'
2191-
# or for specific backends:
2192-
pip install 'ibis-framework[duckdb]' # for DuckDB
2192+
2193+
# ...or specific backends as needed:
2194+
pip install 'ibis-framework[duckdb]' # for DuckDB
21932195
pip install 'ibis-framework[postgres]' # for PostgreSQL
21942196
```
21952197
"""

0 commit comments

Comments
 (0)