Skip to content

Commit cb784e3

Browse files
Merge timescaledb-migration: bump to v0.3.0
* Refactor slicks to exclusively query TimescaleDB securely via SQLAlchemy * docs: Update docs and examples to reference TimescaleDB and SQLAlchemy * Bump version to 0.3.0 (TimescaleDB migration)
1 parent 16dc684 commit cb784e3

8 files changed

Lines changed: 35 additions & 35 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
The home baked data pipeline for **Western Formula Racing**.
88

99
This package handles:
10-
1. **Data Ingestion:** Reliable fetching from InfluxDB 3.0 in wide (columnar) or narrow (legacy EAV) format.
11-
2. **Data Writing:** `WideWriter` encodes CAN frames directly to InfluxDB wide format line protocol.
10+
1. **Data Ingestion:** Reliable fetching from TimescaleDB 3.0 in wide (columnar) or narrow (legacy EAV) format.
11+
2. **Data Writing:** `WideWriter` encodes CAN frames directly to TimescaleDB wide format line protocol.
1212
3. **Movement Detection:** Smart filtering of "Moving" vs "Idle" car states.
1313
4. **Sensor Discovery:** Tools to explore available sensors on any given race day.
1414

@@ -34,7 +34,7 @@ import slicks
3434
from datetime import datetime
3535

3636
# 1. Connect (auto-configured from env vars or explicit)
37-
slicks.connect_influxdb3(db="WFR26")
37+
slicks.connect_timescaledb(table="WFR26")
3838

3939
# 2. Fetch Data — wide format (columnar, preferred)
4040
df = slicks.fetch_telemetry(

docs/advanced_usage.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ You often need to switch between `Development`, `Testing`, and `Production` data
4242
### Option A: Environment Variables (Best for CI/CD)
4343
Set these in your shell or `.env` file before running python:
4444
```bash
45-
export INFLUX_URL="http://production-server:8086"
46-
export INFLUX_DB="Season2026_Final"
45+
export POSTGRES_DSN="http://production-server:8086"
46+
export POSTGRES_TABLE="Season2026_Final"
4747
```
4848

4949
### Option B: Runtime Configuration (Best for Scripts/Notebooks)
5050
```python
5151
import slicks
5252

53-
slicks.connect_influxdb3(
54-
url="http://192.168.1.50:9000",
55-
db="DynoTest_Day1"
53+
slicks.connect_timescaledb(
54+
dsn="http://192.168.1.50:9000",
55+
table="DynoTest_Day1"
5656
)
5757
```
5858

@@ -74,8 +74,8 @@ If you're ingesting raw CAN bus data (e.g., from a replay script or live logger)
7474
from slicks import WideWriter
7575

7676
writer = WideWriter(
77-
url="http://localhost:8086",
78-
token="my-token",
77+
dsn="http://localhost:8086",
78+
"my-token",
7979
bucket="WFR26",
8080
measurement="WFR26",
8181
dbc_path="path/to/WFR26.dbc",

docs/api_reference.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ This document details the functions available in the `slicks` package.
44

55
## Core Functions
66

7-
### `slicks.connect_influxdb3`
7+
### `slicks.connect_timescaledb`
88

9-
Updates the global InfluxDB connection settings dynamically.
9+
Updates the global TimescaleDB connection settings dynamically.
1010

1111
```python
12-
slicks.connect_influxdb3(url=None, token=None, org=None, db=None)
12+
slicks.connect_timescaledb(dsn=None, None, org=None, table=None)
1313
```
14-
- **url** *(str)*: The InfluxDB host URL (e.g., `"http://localhost:8086"`).
14+
- **url** *(str)*: The TimescaleDB host URL (e.g., `"http://localhost:8086"`).
1515
- **token** *(str)*: Authentication token.
1616
- **org** *(str)*: Organization name (default: `"Docs"`).
1717
- **db** *(str)*: Database/Bucket name (default: `"WFR25"`).
@@ -30,7 +30,7 @@ slicks.fetch_telemetry(start_time, end_time, signals=None, client=None,
3030
- **start_time** *(datetime)*: Start of the query range.
3131
- **end_time** *(datetime)*: End of the query range.
3232
- **signals** *(str or list[str])*: A single sensor name or a list of sensor names to fetch. Defaults to standard configuration if `None`.
33-
- **client** *(InfluxDBClient3, optional)*: An existing client instance (advanced use).
33+
- **client** *(TimescaleDBClient3, optional)*: An existing client instance (advanced use).
3434
- **filter_movement** *(bool)*: If `True` (default), strips out rows where the car is stationary.
3535
- **resample** *(str or None)*: Pandas frequency string for resampling (e.g. `"1s"`, `"100ms"`). Pass `None` for raw data.
3636
- **schema** *(str)*: `"wide"` (default, columnar — each signal is a column) or `"narrow"` (legacy EAV — requires pivot).
@@ -105,13 +105,13 @@ slicks.detect_movement_ratio(df, speed_column="INV_Motor_Speed")
105105

106106
### `slicks.WideWriter`
107107

108-
Encodes CAN frames to InfluxDB wide format line protocol and writes them in batches.
108+
Encodes CAN frames to TimescaleDB wide format line protocol and writes them in batches.
109109

110110
```python
111111
from slicks import WideWriter
112112

113113
writer = WideWriter(
114-
url, # InfluxDB URL
114+
url, # TimescaleDB URL
115115
token, # Auth token
116116
bucket, # Bucket/database name (e.g. "WFR26")
117117
measurement, # Measurement name (e.g. "WFR26")
@@ -154,7 +154,7 @@ frame = decode_frame(db, can_id, raw_bytes) # → DecodedFrame or None
154154

155155
### `slicks.frame_to_line_protocol`
156156

157-
Converts a `DecodedFrame` to an InfluxDB line protocol string.
157+
Converts a `DecodedFrame` to an TimescaleDB line protocol string.
158158

159159
```python
160160
from slicks import frame_to_line_protocol

docs/getting_started.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@ pip install -e .
2727
Here is the minimal code needed to connect to the database and download data for a specific sensor.
2828

2929
### Step 1: Import and Configure
30-
The package connects to the InfluxDB database automatically using defaults, but you can configure it explicitly.
30+
The package connects to the TimescaleDB database automatically using defaults, but you can configure it explicitly.
3131

3232
```python
3333
import slicks
3434
from datetime import datetime
3535

3636
# Optional: Configure manually (or use .env file / defaults)
37-
slicks.connect_influxdb3(
38-
url="http://your-influx-server:8086",
39-
token="your-token-here", # Ask Data Lead for your token
37+
slicks.connect_timescaledb(
38+
dsn="http://your-postgres-server:8086",
39+
"your-token-here", # Ask Data Lead for your token
4040
org="Docs",
41-
db="WFR25"
41+
table="WFR25"
4242
)
4343
```
4444

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The home baked data pipeline for **Western Formula Racing**.
44

55
This package handles:
66

7-
1. **Data Ingestion:** Reliable fetching from InfluxDB 3.0.
7+
1. **Data Ingestion:** Reliable fetching from TimescaleDB 3.0.
88

99
2. **Movement Detection:** Smart filtering of "Moving" vs "Idle" car states.
1010

@@ -29,7 +29,7 @@ import slicks
2929
from datetime import datetime
3030

3131
# 1. Connect (Auto-configured or custom)
32-
slicks.connect_influxdb3(db="WFR25", influx_url="http://influxdb:9000", influx_token="apiv3_your_token")
32+
slicks.connect_timescaledb(table="WFR25", dsn="http://postgresdb:9000", "apiv3_your_token")
3333

3434
# 2. Fetch Data (One-liner)
3535
df = slicks.fetch_telemetry(

docs/scanner.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import slicks
99
from datetime import datetime
1010

1111
# Configure connection first
12-
slicks.connect_influxdb3(
13-
url="http://your-server:9000",
14-
token="your-token",
15-
db="WFR25"
12+
slicks.connect_timescaledb(
13+
dsn="http://your-server:9000",
14+
"your-token",
15+
table="WFR25"
1616
)
1717

1818
# Scan for data availability
@@ -73,7 +73,7 @@ slicks.scan_data_availability(
7373
| `start` | `datetime` | *required* | Start of scan range (UTC or timezone-aware) |
7474
| `end` | `datetime` | *required* | End of scan range |
7575
| `timezone` | `str` | `"UTC"` | Timezone for display (e.g., `"America/Toronto"`) |
76-
| `table` | `str` | `None` | Table to scan (defaults to `"iox.{INFLUX_DB}"`) |
76+
| `table` | `str` | `None` | Table to scan (defaults to `"iox.{POSTGRES_TABLE}"`) |
7777
| `bin_size` | `str` | `"hour"` | Granularity: `"hour"` or `"day"` |
7878
| `include_counts` | `bool` | `True` | Include row counts (slightly slower if `True`) |
7979
| `show_progress` | `bool` | `True` | Show progress bar during scan |

examples/end_to_end.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def main():
1414
# Configure connection.
1515
# For CI, these are pulled from environment variables (GitHub Secrets).
1616
# For local use, you can set these in a .env file or call configure() directly.
17-
slicks.connect_influxdb3(
18-
url=os.getenv("INFLUX_URL"),
19-
token=os.getenv("INFLUX_TOKEN"),
17+
slicks.connect_timescaledb(
18+
dsn=os.getenv("POSTGRES_DSN"),
19+
os.getenv(""),
2020
org=os.getenv("INFLUX_ORG"),
21-
db=os.getenv("INFLUX_DB")
21+
table=os.getenv("POSTGRES_TABLE")
2222
)
2323

2424
# ---------------------------------------------------------

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "slicks"
7-
version = "0.2.3"
7+
version = "0.3.0"
88
description = "The home baked data pipeline for Western Formula Racing"
99
readme = "README.md"
1010
authors = [

0 commit comments

Comments
 (0)