|
1 |
| -# sqlalchemy-parseable |
2 |
| -A DBAPI and SQLAlchemy dialect for Parseable |
| 1 | +# SQLAlchemy Parseable Connector for Apache Superset |
| 2 | + |
| 3 | +A SQLAlchemy dialect and DBAPI implementation for connecting Apache Superset to Parseable, enabling seamless data visualization and analytics of your log data. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Full SQLAlchemy dialect implementation for Parseable |
| 8 | +- Support for timestamp-based queries |
| 9 | +- Automatic schema detection |
| 10 | +- Support for special characters in table names (e.g., "ingress-nginx") |
| 11 | +- Type mapping from Parseable to SQLAlchemy types |
| 12 | +- Connection pooling and management |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- Python 3.11.6 or higher |
| 17 | +- Apache Superset |
| 18 | +- A running Parseable instance |
| 19 | + |
| 20 | +## Installation |
| 21 | + |
| 22 | +### 1. Set Up Python Environment |
| 23 | + |
| 24 | +First, create and activate a Python virtual environment: |
| 25 | + |
| 26 | +```bash |
| 27 | +python3 -m venv venv |
| 28 | +source venv/bin/activate # On Linux/Mac |
| 29 | +# or |
| 30 | +.\venv\Scripts\activate # On Windows |
| 31 | +``` |
| 32 | + |
| 33 | +### 2. Install and Configure Superset |
| 34 | + |
| 35 | +Install Apache Superset and perform initial setup: |
| 36 | + |
| 37 | +```bash |
| 38 | +# Install Superset |
| 39 | +pip install apache-superset |
| 40 | + |
| 41 | +# Configure Superset |
| 42 | +export SUPERSET_SECRET_KEY=your-secure-secret-key |
| 43 | +export FLASK_APP=superset |
| 44 | + |
| 45 | +# Initialize the database |
| 46 | +superset db upgrade |
| 47 | + |
| 48 | +# Create an admin user |
| 49 | +superset fab create-admin |
| 50 | + |
| 51 | +# Load initial data |
| 52 | +superset init |
| 53 | +``` |
| 54 | + |
| 55 | +### 3. Install Parseable Connector |
| 56 | + |
| 57 | +Install the Parseable connector in development mode: |
| 58 | + |
| 59 | +```bash |
| 60 | +cd sqlalchemy-parseable |
| 61 | +pip install -e . |
| 62 | +``` |
| 63 | + |
| 64 | +## Running Superset |
| 65 | + |
| 66 | +Start the Superset development server: |
| 67 | + |
| 68 | +```bash |
| 69 | +superset run -p 8088 --with-threads --reload --debugger |
| 70 | +``` |
| 71 | + |
| 72 | +Access Superset at http://localhost:8088 |
| 73 | + |
| 74 | +## Connecting to Parseable |
| 75 | + |
| 76 | +1. In the Superset UI, go to Data → Databases → + Database |
| 77 | +2. Select "Other" as the database type |
| 78 | +3. Use the following SQLAlchemy URI format: |
| 79 | + ``` |
| 80 | + parseable://username:password@host:port/table_name |
| 81 | + ``` |
| 82 | + Example: |
| 83 | + ``` |
| 84 | + parseable://admin:[email protected]:443/ingress-nginx |
| 85 | + ``` |
| 86 | + |
| 87 | +## Query Examples |
| 88 | + |
| 89 | +The connector supports standard SQL queries with some Parseable-specific features: |
| 90 | + |
| 91 | +```sql |
| 92 | +-- Basic query with time range |
| 93 | +SELECT method, status, COUNT(*) as count |
| 94 | +FROM ingress-nginx |
| 95 | +WHERE p_timestamp >= '2024-01-01T00:00:00Z' |
| 96 | + AND p_timestamp < '2024-01-02T00:00:00Z' |
| 97 | +GROUP BY method, status; |
| 98 | + |
| 99 | +-- Status code analysis |
| 100 | +SELECT status, COUNT(*) as count |
| 101 | +FROM ingress-nginx |
| 102 | +WHERE p_timestamp >= '2024-01-01T00:00:00Z' |
| 103 | +GROUP BY status; |
| 104 | +``` |
| 105 | + |
| 106 | +## Development |
| 107 | + |
| 108 | +The connector implements several key components: |
| 109 | + |
| 110 | +- `ParseableDialect`: SQLAlchemy dialect implementation |
| 111 | +- `ParseableClient`: HTTP client for Parseable API |
| 112 | +- `ParseableConnection`: DBAPI connection implementation |
| 113 | +- `ParseableCursor`: DBAPI cursor implementation |
| 114 | + |
| 115 | +## Features and Limitations |
| 116 | + |
| 117 | +### Supported Features |
| 118 | +- Query execution with time range filtering |
| 119 | +- Schema inspection |
| 120 | +- Column type mapping |
| 121 | +- Connection testing |
| 122 | +- Table existence checking |
| 123 | + |
| 124 | +### Current Limitations |
| 125 | +- No transaction support (Parseable is append-only) |
| 126 | +- No write operations support |
| 127 | +- Limited to supported Parseable query operations |
| 128 | + |
| 129 | +## Troubleshooting |
| 130 | + |
| 131 | +### Common Issues |
| 132 | + |
| 133 | +1. Connection Errors |
| 134 | + - Verify Parseable host and port are correct |
| 135 | + - Ensure credentials are valid |
| 136 | + - Check if table name exists in Parseable |
| 137 | + |
| 138 | +2. Query Errors |
| 139 | + - Verify time range format (should be ISO8601) |
| 140 | + - Check if column names exist in schema |
| 141 | + - Ensure proper quoting for table names with special characters |
| 142 | + |
| 143 | +## Contributing |
| 144 | + |
| 145 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 146 | + |
| 147 | +## License |
| 148 | + |
| 149 | +[Apache License 2.0](LICENSE) |
0 commit comments