@@ -2149,27 +2149,27 @@ def connect_to_table(connection_string: str) -> Any:
2149
2149
--------
2150
2150
Connect to a DuckDB table:
2151
2151
2152
- ```python
2152
+ ```{ python}
2153
2153
import pointblank as pb
2154
2154
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")
2157
2160
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 )
2160
2163
```
2161
2164
2162
2165
If you omit the table specification, you'll get helpful guidance:
2163
2166
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}")
2170
2170
```
2171
2171
2172
- Backend -specific connection examples:
2172
+ Here are some backend -specific connection examples:
2173
2173
2174
2174
```python
2175
2175
# PostgreSQL
@@ -2187,9 +2187,11 @@ def connect_to_table(connection_string: str) -> Any:
2187
2187
This function requires the Ibis library with appropriate backend drivers:
2188
2188
2189
2189
```bash
2190
+ # You can install a set of common backends:
2190
2191
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
2193
2195
pip install 'ibis-framework[postgres]' # for PostgreSQL
2194
2196
```
2195
2197
"""
0 commit comments