@@ -13,6 +13,7 @@ This project packages a SQLAlchemy dialect and lightweight DBAPI 2.0 adapter tha
1313- Lightweight DBAPI implementation that maps Opteryx types to SQLAlchemy while surfacing DatabaseError/OperationalError semantics.
1414- Compatible with SQLAlchemy 2.x usage patterns, including context-managed engines and ` text ` queries.
1515- Work with pandas, dbt, or other tooling that understands SQLAlchemy engines.
16+ - ** Comprehensive debug logging** for troubleshooting connection, authentication, and query execution issues.
1617- Install from PyPI (` pip install opteryx-sqlalchemy ` ) or lock into editable mode for development.
1718
1819---
@@ -25,16 +26,26 @@ Use the following SQLAlchemy URL format:
2526opteryx://[username:token@]host[:port]/[database][?ssl=true&timeout=60]
2627```
2728
28- Example:
29- - ` opteryx://user:mytoken@opteryx.app:443/default?ssl=true `
29+ Examples:
30+ - ** Opteryx Cloud (with token)** : ` opteryx://myusername:mytoken@opteryx.app:443/default?ssl=true `
31+ - ** Local Opteryx (no auth)** : ` opteryx://localhost:8000/default `
32+ - ** Self-hosted (with auth)** : ` opteryx://user:token@opteryx.example.com/my_database?ssl=true `
3033
3134Notes:
3235- If ` ssl=true ` or port 443 is used, the driver will use HTTPS. The default port is 8000 for plain HTTP, 443 for HTTPS.
3336- Pass a token in place of a password for bearer token authentication.
3437
3538---
3639
37- ## Installation
40+ ## Getting Started
41+
42+ ### 1. Create an Opteryx Account
43+
44+ If you don't have an Opteryx account yet, register at: ** https://opteryx.app/auth/register.html **
45+
46+ Once registered, you'll receive credentials (username and token) needed to authenticate.
47+
48+ ### 2. Install the Package
3849
3950Install the published package from PyPI in any environment:
4051
@@ -59,11 +70,14 @@ Basic usage with SQLAlchemy 2.x:
5970``` python
6071from sqlalchemy import create_engine, text
6172
62- # Basic connection (no token)
63- engine = create_engine(" opteryx://opteryx.app/default?ssl=true" )
73+ # Connect to Opteryx Cloud with your credentials
74+ engine = create_engine(
75+ " opteryx://myusername:mytoken@opteryx.app:443/default?ssl=true"
76+ )
6477
6578with engine.connect() as conn:
66- result = conn.execute(text(" SELECT id, name FROM users LIMIT 10" ))
79+ # Run a simple query
80+ result = conn.execute(text(" SELECT * FROM public.examples.users LIMIT 10" ))
6781 for row in result:
6882 print (row)
6983
@@ -73,12 +87,34 @@ with engine.connect() as conn:
7387 print (result.fetchall())
7488```
7589
76- Token authentication example:
90+ ** Connection String Format:**
91+ - Replace ` myusername ` with your Opteryx username
92+ - Replace ` mytoken ` with your Opteryx authentication token
93+ - For Opteryx Cloud, always use ` opteryx.app:443 ` with ` ssl=true `
94+
95+ ---
96+
97+ ## Debug Logging 🔍
98+
99+ The dialect includes comprehensive logging to help troubleshoot issues. Enable it with Python's standard ` logging ` module:
77100
78101``` python
79- engine = create_engine(" opteryx://username:password@opteryx.app:443/opteryx?ssl=true" )
102+ import logging
103+
104+ # Enable INFO level for query timing and status
105+ logging.basicConfig()
106+ logging.getLogger(" sqlalchemy.dialects.opteryx" ).setLevel(logging.INFO )
107+
108+ # Or enable DEBUG level for detailed request/response information
109+ logging.getLogger(" sqlalchemy.dialects.opteryx" ).setLevel(logging.DEBUG )
80110```
81111
112+ ** What you'll see:**
113+ - ** INFO** : Authentication status, query completion times, row counts, long-running query progress
114+ - ** DEBUG** : HTTP requests/responses, query text, parameters, state transitions, execution IDs
115+ - ** WARNING** : Authentication failures, non-fatal issues
116+ - ** ERROR** : Failures with full context including HTTP status codes
117+
82118---
83119
84120## Using with pandas
@@ -89,9 +125,11 @@ You can use `pandas.read_sql_query` with a SQLAlchemy connection:
89125import pandas as pd
90126from sqlalchemy import create_engine
91127
92- engine = create_engine(" opteryx://opteryx.app/default?ssl=true" )
128+ engine = create_engine(
129+ " opteryx://myusername:mytoken@opteryx.app:443/default?ssl=true"
130+ )
93131with engine.connect() as conn:
94- df = pd.read_sql_query(" SELECT * FROM users LIMIT 100" , conn)
132+ df = pd.read_sql_query(" SELECT * FROM public.examples. users LIMIT 100" , conn)
95133 print (df.head())
96134```
97135
0 commit comments