streaming-sql-engine 0.1.0__tar.gz → 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/PKG-INFO +140 -11
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/README.md +139 -10
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/pyproject.toml +1 -1
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/setup.py +1 -1
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/__init__.py +2 -2
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine.egg-info/PKG-INFO +140 -11
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/LICENSE +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/MANIFEST.in +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/APACHE_DRILL_COMPARISON.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/API_JOIN_OPERATIONS.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/BEST_USE_CASES.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/COMPREHENSIVE_DOCUMENTATION.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/DEVELOPER_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/DUCKDB_COMPARISON.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/HOW_TO_ADD_TO_PROJECT.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/INSTALLATION.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/MULTI_SOURCE_EXAMPLE_README.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/MYSQL_USAGE.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/PERFORMANCE.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/QUICK_START.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/TECHNICAL_DOCUMENTATION.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/USER_GUIDE.md +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/requirements.txt +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/setup.cfg +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/db_connector.py +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/engine.py +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/evaluator.py +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/executor.py +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/jsonl_executor.py +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/operators.py +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/parser.py +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/planner.py +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine.egg-info/SOURCES.txt +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine.egg-info/dependency_links.txt +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine.egg-info/requires.txt +0 -0
- {streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: streaming-sql-engine
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A lightweight SQL execution engine for streaming row-by-row queries with joins
|
|
5
5
|
Home-page: https://github.com/Ierofantis/streaming-sql-engine
|
|
6
6
|
Author: Ierofantis
|
|
@@ -42,6 +42,77 @@ Dynamic: requires-python
|
|
|
42
42
|
|
|
43
43
|
A lightweight Python library for executing SQL queries with joins in a streaming, row-by-row fashion without loading full tables into memory.
|
|
44
44
|
|
|
45
|
+
## What This Library Does
|
|
46
|
+
|
|
47
|
+
**Streaming SQL Join Engine** is a Python library that lets you write SQL queries to join data from **any source** - CSV files, REST APIs, database tables, JSON files, or custom Python functions - **without copying or loading the data into a database first**.
|
|
48
|
+
|
|
49
|
+
### The Core Problem It Solves
|
|
50
|
+
|
|
51
|
+
Traditionally, to join data from different sources (like multiple APIs, CSV files, or databases), you need to:
|
|
52
|
+
|
|
53
|
+
1. Extract data from each source
|
|
54
|
+
2. Load it into a database or data warehouse
|
|
55
|
+
3. Write SQL queries against that database
|
|
56
|
+
4. Export the results
|
|
57
|
+
|
|
58
|
+
This library eliminates steps 2 and 4. You can write SQL queries directly against your original data sources, and the engine processes them row-by-row in memory, streaming results as they're computed.
|
|
59
|
+
|
|
60
|
+
### How It Works
|
|
61
|
+
|
|
62
|
+
1. **Register Data Sources**: You register any Python function that yields dictionaries (rows) as a "table":
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
def my_api_source():
|
|
66
|
+
response = requests.get("https://api.example.com/data")
|
|
67
|
+
for item in response.json():
|
|
68
|
+
yield {"id": item["id"], "name": item["name"]}
|
|
69
|
+
|
|
70
|
+
engine.register("my_table", my_api_source)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
2. **Write SQL Queries**: Use standard SQL syntax to join and filter:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
query = """
|
|
77
|
+
SELECT t1.name, t2.value
|
|
78
|
+
FROM table1 t1
|
|
79
|
+
JOIN table2 t2 ON t1.id = t2.id
|
|
80
|
+
WHERE t1.status = 'active'
|
|
81
|
+
"""
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
3. **Stream Results**: The engine processes your query row-by-row, yielding results as they're computed:
|
|
85
|
+
```python
|
|
86
|
+
for row in engine.query(query):
|
|
87
|
+
print(row) # Process each row immediately, no waiting for full result set
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Key Characteristics
|
|
91
|
+
|
|
92
|
+
- **No Data Copying**: Data stays in its original source (API, file, database). Only the data needed for joins is temporarily cached.
|
|
93
|
+
- **Memory Efficient**: Uses iterator pipelines - processes one row at a time instead of loading entire tables.
|
|
94
|
+
- **Source Agnostic**: Works with any data source you can write a Python function for (APIs, CSVs, databases, JSON files, etc.).
|
|
95
|
+
- **SQL Interface**: Familiar SQL syntax for joins and filtering, even when joining data from completely different systems.
|
|
96
|
+
- **Streaming Execution**: Results are yielded immediately as they're computed, enabling real-time processing of large datasets.
|
|
97
|
+
|
|
98
|
+
### Use Cases
|
|
99
|
+
|
|
100
|
+
- **API Data Integration**: Join data from multiple REST APIs without setting up a database
|
|
101
|
+
- **File Processing**: Join CSV files, JSON files, or other file formats using SQL
|
|
102
|
+
- **Cross-System Queries**: Query data from PostgreSQL, MySQL, APIs, and files in a single SQL query
|
|
103
|
+
- **Real-Time Analytics**: Process streaming data sources with SQL joins
|
|
104
|
+
- **ETL Simplification**: Replace complex ETL pipelines with simple SQL queries
|
|
105
|
+
- **Prototyping**: Quickly explore relationships between different data sources
|
|
106
|
+
|
|
107
|
+
### What Makes It Different
|
|
108
|
+
|
|
109
|
+
Unlike traditional databases or query engines:
|
|
110
|
+
|
|
111
|
+
- **No setup required**: No database server, no schema creation, no data loading
|
|
112
|
+
- **Works with live data**: Queries execute against current data from APIs or files
|
|
113
|
+
- **Minimal memory footprint**: Only caches what's needed for joins, not entire tables
|
|
114
|
+
- **Python-native**: Integrates seamlessly with Python code and data sources
|
|
115
|
+
|
|
45
116
|
## Features
|
|
46
117
|
|
|
47
118
|
- **Streaming execution**: Processes queries row-by-row using Python generators
|
|
@@ -185,6 +256,73 @@ for row in engine.query(query):
|
|
|
185
256
|
# {'name': 'Charlie', 'dept_name': 'Engineering'}
|
|
186
257
|
```
|
|
187
258
|
|
|
259
|
+
## Real-World Example: Joining Multiple APIs
|
|
260
|
+
|
|
261
|
+
Join data from multiple free public APIs using SQL:
|
|
262
|
+
|
|
263
|
+
```python
|
|
264
|
+
# Install: pip install streaming-sql-engine
|
|
265
|
+
import requests
|
|
266
|
+
from streaming_sql_engine import Engine
|
|
267
|
+
|
|
268
|
+
# Define API sources
|
|
269
|
+
def jsonplaceholder_users_api():
|
|
270
|
+
"""Fetch users from JSONPlaceholder API."""
|
|
271
|
+
response = requests.get("https://jsonplaceholder.typicode.com/users")
|
|
272
|
+
for user in response.json():
|
|
273
|
+
yield {
|
|
274
|
+
"user_id": user["id"],
|
|
275
|
+
"user_name": user["name"],
|
|
276
|
+
"user_email": user["email"],
|
|
277
|
+
"user_city": user["address"]["city"],
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
def jsonplaceholder_posts_api():
|
|
281
|
+
"""Fetch posts from JSONPlaceholder API."""
|
|
282
|
+
response = requests.get("https://jsonplaceholder.typicode.com/posts")
|
|
283
|
+
for post in response.json():
|
|
284
|
+
yield {
|
|
285
|
+
"post_id": post["id"],
|
|
286
|
+
"user_id": post["userId"],
|
|
287
|
+
"post_title": post["title"],
|
|
288
|
+
"post_body": post["body"][:100],
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
def rest_countries_api():
|
|
292
|
+
"""Fetch countries from REST Countries API."""
|
|
293
|
+
response = requests.get("https://restcountries.com/v3.1/all")
|
|
294
|
+
for country in response.json():
|
|
295
|
+
yield {
|
|
296
|
+
"country_code": country.get("cca2", ""),
|
|
297
|
+
"country_name": country["name"].get("common", ""),
|
|
298
|
+
"capital": country.get("capital", ["N/A"])[0] if country.get("capital") else "N/A",
|
|
299
|
+
"population": country.get("population", 0),
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
# Create engine and register sources
|
|
303
|
+
engine = Engine()
|
|
304
|
+
engine.register("users", jsonplaceholder_users_api)
|
|
305
|
+
engine.register("posts", jsonplaceholder_posts_api)
|
|
306
|
+
engine.register("countries", rest_countries_api)
|
|
307
|
+
|
|
308
|
+
# Join Users + Posts from different APIs
|
|
309
|
+
query = """
|
|
310
|
+
SELECT
|
|
311
|
+
users.user_name,
|
|
312
|
+
users.user_email,
|
|
313
|
+
posts.post_title,
|
|
314
|
+
posts.post_body
|
|
315
|
+
FROM users
|
|
316
|
+
JOIN posts ON users.user_id = posts.user_id
|
|
317
|
+
WHERE users.user_id <= 3
|
|
318
|
+
"""
|
|
319
|
+
|
|
320
|
+
for row in engine.query(query):
|
|
321
|
+
print(f"{row['user_name']} ({row['user_email']}): {row['post_title']}")
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
This example demonstrates joining data from multiple REST APIs using standard SQL syntax - no ETL, no data copying, just pure SQL joins across different data sources!
|
|
325
|
+
|
|
188
326
|
## Supported SQL Features
|
|
189
327
|
|
|
190
328
|
### SELECT
|
|
@@ -267,15 +405,6 @@ The engine raises clear exceptions for:
|
|
|
267
405
|
- **Streaming**: Results are yielded as soon as they're produced
|
|
268
406
|
- **No buffering**: Intermediate results are not fully materialized
|
|
269
407
|
|
|
270
|
-
## Documentation
|
|
271
|
-
|
|
272
|
-
- **[TECHNICAL_DOCUMENTATION.md](TECHNICAL_DOCUMENTATION.md)**: Complete technical documentation explaining architecture, algorithms, and design decisions
|
|
273
|
-
- **[DEVELOPER_GUIDE.md](DEVELOPER_GUIDE.md)**: Guide for developers who want to understand, modify, or extend the codebase
|
|
274
|
-
- **[PERFORMANCE.md](PERFORMANCE.md)**: Performance comparison with database joins and optimization tips
|
|
275
|
-
- **[MYSQL_USAGE.md](MYSQL_USAGE.md)**: MySQL-specific usage guide
|
|
276
|
-
- **[QUICK_START.md](QUICK_START.md)**: Quick start guide for new users
|
|
277
|
-
- **[INSTALLATION.md](INSTALLATION.md)**: Detailed installation instructions
|
|
278
|
-
|
|
279
408
|
## Installation from PyPI
|
|
280
409
|
|
|
281
410
|
Once published, you can install the package directly from PyPI:
|
|
@@ -286,4 +415,4 @@ pip install streaming-sql-engine
|
|
|
286
415
|
|
|
287
416
|
## License
|
|
288
417
|
|
|
289
|
-
MIT License
|
|
418
|
+
MIT License
|
|
@@ -2,6 +2,77 @@
|
|
|
2
2
|
|
|
3
3
|
A lightweight Python library for executing SQL queries with joins in a streaming, row-by-row fashion without loading full tables into memory.
|
|
4
4
|
|
|
5
|
+
## What This Library Does
|
|
6
|
+
|
|
7
|
+
**Streaming SQL Join Engine** is a Python library that lets you write SQL queries to join data from **any source** - CSV files, REST APIs, database tables, JSON files, or custom Python functions - **without copying or loading the data into a database first**.
|
|
8
|
+
|
|
9
|
+
### The Core Problem It Solves
|
|
10
|
+
|
|
11
|
+
Traditionally, to join data from different sources (like multiple APIs, CSV files, or databases), you need to:
|
|
12
|
+
|
|
13
|
+
1. Extract data from each source
|
|
14
|
+
2. Load it into a database or data warehouse
|
|
15
|
+
3. Write SQL queries against that database
|
|
16
|
+
4. Export the results
|
|
17
|
+
|
|
18
|
+
This library eliminates steps 2 and 4. You can write SQL queries directly against your original data sources, and the engine processes them row-by-row in memory, streaming results as they're computed.
|
|
19
|
+
|
|
20
|
+
### How It Works
|
|
21
|
+
|
|
22
|
+
1. **Register Data Sources**: You register any Python function that yields dictionaries (rows) as a "table":
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
def my_api_source():
|
|
26
|
+
response = requests.get("https://api.example.com/data")
|
|
27
|
+
for item in response.json():
|
|
28
|
+
yield {"id": item["id"], "name": item["name"]}
|
|
29
|
+
|
|
30
|
+
engine.register("my_table", my_api_source)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
2. **Write SQL Queries**: Use standard SQL syntax to join and filter:
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
query = """
|
|
37
|
+
SELECT t1.name, t2.value
|
|
38
|
+
FROM table1 t1
|
|
39
|
+
JOIN table2 t2 ON t1.id = t2.id
|
|
40
|
+
WHERE t1.status = 'active'
|
|
41
|
+
"""
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
3. **Stream Results**: The engine processes your query row-by-row, yielding results as they're computed:
|
|
45
|
+
```python
|
|
46
|
+
for row in engine.query(query):
|
|
47
|
+
print(row) # Process each row immediately, no waiting for full result set
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Key Characteristics
|
|
51
|
+
|
|
52
|
+
- **No Data Copying**: Data stays in its original source (API, file, database). Only the data needed for joins is temporarily cached.
|
|
53
|
+
- **Memory Efficient**: Uses iterator pipelines - processes one row at a time instead of loading entire tables.
|
|
54
|
+
- **Source Agnostic**: Works with any data source you can write a Python function for (APIs, CSVs, databases, JSON files, etc.).
|
|
55
|
+
- **SQL Interface**: Familiar SQL syntax for joins and filtering, even when joining data from completely different systems.
|
|
56
|
+
- **Streaming Execution**: Results are yielded immediately as they're computed, enabling real-time processing of large datasets.
|
|
57
|
+
|
|
58
|
+
### Use Cases
|
|
59
|
+
|
|
60
|
+
- **API Data Integration**: Join data from multiple REST APIs without setting up a database
|
|
61
|
+
- **File Processing**: Join CSV files, JSON files, or other file formats using SQL
|
|
62
|
+
- **Cross-System Queries**: Query data from PostgreSQL, MySQL, APIs, and files in a single SQL query
|
|
63
|
+
- **Real-Time Analytics**: Process streaming data sources with SQL joins
|
|
64
|
+
- **ETL Simplification**: Replace complex ETL pipelines with simple SQL queries
|
|
65
|
+
- **Prototyping**: Quickly explore relationships between different data sources
|
|
66
|
+
|
|
67
|
+
### What Makes It Different
|
|
68
|
+
|
|
69
|
+
Unlike traditional databases or query engines:
|
|
70
|
+
|
|
71
|
+
- **No setup required**: No database server, no schema creation, no data loading
|
|
72
|
+
- **Works with live data**: Queries execute against current data from APIs or files
|
|
73
|
+
- **Minimal memory footprint**: Only caches what's needed for joins, not entire tables
|
|
74
|
+
- **Python-native**: Integrates seamlessly with Python code and data sources
|
|
75
|
+
|
|
5
76
|
## Features
|
|
6
77
|
|
|
7
78
|
- **Streaming execution**: Processes queries row-by-row using Python generators
|
|
@@ -145,6 +216,73 @@ for row in engine.query(query):
|
|
|
145
216
|
# {'name': 'Charlie', 'dept_name': 'Engineering'}
|
|
146
217
|
```
|
|
147
218
|
|
|
219
|
+
## Real-World Example: Joining Multiple APIs
|
|
220
|
+
|
|
221
|
+
Join data from multiple free public APIs using SQL:
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
# Install: pip install streaming-sql-engine
|
|
225
|
+
import requests
|
|
226
|
+
from streaming_sql_engine import Engine
|
|
227
|
+
|
|
228
|
+
# Define API sources
|
|
229
|
+
def jsonplaceholder_users_api():
|
|
230
|
+
"""Fetch users from JSONPlaceholder API."""
|
|
231
|
+
response = requests.get("https://jsonplaceholder.typicode.com/users")
|
|
232
|
+
for user in response.json():
|
|
233
|
+
yield {
|
|
234
|
+
"user_id": user["id"],
|
|
235
|
+
"user_name": user["name"],
|
|
236
|
+
"user_email": user["email"],
|
|
237
|
+
"user_city": user["address"]["city"],
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
def jsonplaceholder_posts_api():
|
|
241
|
+
"""Fetch posts from JSONPlaceholder API."""
|
|
242
|
+
response = requests.get("https://jsonplaceholder.typicode.com/posts")
|
|
243
|
+
for post in response.json():
|
|
244
|
+
yield {
|
|
245
|
+
"post_id": post["id"],
|
|
246
|
+
"user_id": post["userId"],
|
|
247
|
+
"post_title": post["title"],
|
|
248
|
+
"post_body": post["body"][:100],
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
def rest_countries_api():
|
|
252
|
+
"""Fetch countries from REST Countries API."""
|
|
253
|
+
response = requests.get("https://restcountries.com/v3.1/all")
|
|
254
|
+
for country in response.json():
|
|
255
|
+
yield {
|
|
256
|
+
"country_code": country.get("cca2", ""),
|
|
257
|
+
"country_name": country["name"].get("common", ""),
|
|
258
|
+
"capital": country.get("capital", ["N/A"])[0] if country.get("capital") else "N/A",
|
|
259
|
+
"population": country.get("population", 0),
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
# Create engine and register sources
|
|
263
|
+
engine = Engine()
|
|
264
|
+
engine.register("users", jsonplaceholder_users_api)
|
|
265
|
+
engine.register("posts", jsonplaceholder_posts_api)
|
|
266
|
+
engine.register("countries", rest_countries_api)
|
|
267
|
+
|
|
268
|
+
# Join Users + Posts from different APIs
|
|
269
|
+
query = """
|
|
270
|
+
SELECT
|
|
271
|
+
users.user_name,
|
|
272
|
+
users.user_email,
|
|
273
|
+
posts.post_title,
|
|
274
|
+
posts.post_body
|
|
275
|
+
FROM users
|
|
276
|
+
JOIN posts ON users.user_id = posts.user_id
|
|
277
|
+
WHERE users.user_id <= 3
|
|
278
|
+
"""
|
|
279
|
+
|
|
280
|
+
for row in engine.query(query):
|
|
281
|
+
print(f"{row['user_name']} ({row['user_email']}): {row['post_title']}")
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
This example demonstrates joining data from multiple REST APIs using standard SQL syntax - no ETL, no data copying, just pure SQL joins across different data sources!
|
|
285
|
+
|
|
148
286
|
## Supported SQL Features
|
|
149
287
|
|
|
150
288
|
### SELECT
|
|
@@ -227,15 +365,6 @@ The engine raises clear exceptions for:
|
|
|
227
365
|
- **Streaming**: Results are yielded as soon as they're produced
|
|
228
366
|
- **No buffering**: Intermediate results are not fully materialized
|
|
229
367
|
|
|
230
|
-
## Documentation
|
|
231
|
-
|
|
232
|
-
- **[TECHNICAL_DOCUMENTATION.md](TECHNICAL_DOCUMENTATION.md)**: Complete technical documentation explaining architecture, algorithms, and design decisions
|
|
233
|
-
- **[DEVELOPER_GUIDE.md](DEVELOPER_GUIDE.md)**: Guide for developers who want to understand, modify, or extend the codebase
|
|
234
|
-
- **[PERFORMANCE.md](PERFORMANCE.md)**: Performance comparison with database joins and optimization tips
|
|
235
|
-
- **[MYSQL_USAGE.md](MYSQL_USAGE.md)**: MySQL-specific usage guide
|
|
236
|
-
- **[QUICK_START.md](QUICK_START.md)**: Quick start guide for new users
|
|
237
|
-
- **[INSTALLATION.md](INSTALLATION.md)**: Detailed installation instructions
|
|
238
|
-
|
|
239
368
|
## Installation from PyPI
|
|
240
369
|
|
|
241
370
|
Once published, you can install the package directly from PyPI:
|
|
@@ -246,4 +375,4 @@ pip install streaming-sql-engine
|
|
|
246
375
|
|
|
247
376
|
## License
|
|
248
377
|
|
|
249
|
-
MIT License
|
|
378
|
+
MIT License
|
|
@@ -12,7 +12,7 @@ with open("requirements.txt", "r", encoding="utf-8") as fh:
|
|
|
12
12
|
|
|
13
13
|
setup(
|
|
14
14
|
name="streaming-sql-engine",
|
|
15
|
-
version="0.1.
|
|
15
|
+
version="0.1.2",
|
|
16
16
|
author="Ierofantis",
|
|
17
17
|
author_email="teopanta1986@gmail.com",
|
|
18
18
|
description="A lightweight SQL execution engine for streaming row-by-row queries with joins",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"""
|
|
2
|
-
|
|
2
|
+
Streaming SQL Join Engine
|
|
3
3
|
|
|
4
4
|
A lightweight SQL execution engine that processes queries row-by-row
|
|
5
5
|
without loading full tables into memory.
|
|
@@ -16,7 +16,7 @@ from .db_connector import (
|
|
|
16
16
|
create_table_source
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
-
__version__ = "0.1.
|
|
19
|
+
__version__ = "0.1.2"
|
|
20
20
|
__all__ = [
|
|
21
21
|
"Engine",
|
|
22
22
|
"PostgreSQLPool",
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: streaming-sql-engine
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A lightweight SQL execution engine for streaming row-by-row queries with joins
|
|
5
5
|
Home-page: https://github.com/Ierofantis/streaming-sql-engine
|
|
6
6
|
Author: Ierofantis
|
|
@@ -42,6 +42,77 @@ Dynamic: requires-python
|
|
|
42
42
|
|
|
43
43
|
A lightweight Python library for executing SQL queries with joins in a streaming, row-by-row fashion without loading full tables into memory.
|
|
44
44
|
|
|
45
|
+
## What This Library Does
|
|
46
|
+
|
|
47
|
+
**Streaming SQL Join Engine** is a Python library that lets you write SQL queries to join data from **any source** - CSV files, REST APIs, database tables, JSON files, or custom Python functions - **without copying or loading the data into a database first**.
|
|
48
|
+
|
|
49
|
+
### The Core Problem It Solves
|
|
50
|
+
|
|
51
|
+
Traditionally, to join data from different sources (like multiple APIs, CSV files, or databases), you need to:
|
|
52
|
+
|
|
53
|
+
1. Extract data from each source
|
|
54
|
+
2. Load it into a database or data warehouse
|
|
55
|
+
3. Write SQL queries against that database
|
|
56
|
+
4. Export the results
|
|
57
|
+
|
|
58
|
+
This library eliminates steps 2 and 4. You can write SQL queries directly against your original data sources, and the engine processes them row-by-row in memory, streaming results as they're computed.
|
|
59
|
+
|
|
60
|
+
### How It Works
|
|
61
|
+
|
|
62
|
+
1. **Register Data Sources**: You register any Python function that yields dictionaries (rows) as a "table":
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
def my_api_source():
|
|
66
|
+
response = requests.get("https://api.example.com/data")
|
|
67
|
+
for item in response.json():
|
|
68
|
+
yield {"id": item["id"], "name": item["name"]}
|
|
69
|
+
|
|
70
|
+
engine.register("my_table", my_api_source)
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
2. **Write SQL Queries**: Use standard SQL syntax to join and filter:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
query = """
|
|
77
|
+
SELECT t1.name, t2.value
|
|
78
|
+
FROM table1 t1
|
|
79
|
+
JOIN table2 t2 ON t1.id = t2.id
|
|
80
|
+
WHERE t1.status = 'active'
|
|
81
|
+
"""
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
3. **Stream Results**: The engine processes your query row-by-row, yielding results as they're computed:
|
|
85
|
+
```python
|
|
86
|
+
for row in engine.query(query):
|
|
87
|
+
print(row) # Process each row immediately, no waiting for full result set
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Key Characteristics
|
|
91
|
+
|
|
92
|
+
- **No Data Copying**: Data stays in its original source (API, file, database). Only the data needed for joins is temporarily cached.
|
|
93
|
+
- **Memory Efficient**: Uses iterator pipelines - processes one row at a time instead of loading entire tables.
|
|
94
|
+
- **Source Agnostic**: Works with any data source you can write a Python function for (APIs, CSVs, databases, JSON files, etc.).
|
|
95
|
+
- **SQL Interface**: Familiar SQL syntax for joins and filtering, even when joining data from completely different systems.
|
|
96
|
+
- **Streaming Execution**: Results are yielded immediately as they're computed, enabling real-time processing of large datasets.
|
|
97
|
+
|
|
98
|
+
### Use Cases
|
|
99
|
+
|
|
100
|
+
- **API Data Integration**: Join data from multiple REST APIs without setting up a database
|
|
101
|
+
- **File Processing**: Join CSV files, JSON files, or other file formats using SQL
|
|
102
|
+
- **Cross-System Queries**: Query data from PostgreSQL, MySQL, APIs, and files in a single SQL query
|
|
103
|
+
- **Real-Time Analytics**: Process streaming data sources with SQL joins
|
|
104
|
+
- **ETL Simplification**: Replace complex ETL pipelines with simple SQL queries
|
|
105
|
+
- **Prototyping**: Quickly explore relationships between different data sources
|
|
106
|
+
|
|
107
|
+
### What Makes It Different
|
|
108
|
+
|
|
109
|
+
Unlike traditional databases or query engines:
|
|
110
|
+
|
|
111
|
+
- **No setup required**: No database server, no schema creation, no data loading
|
|
112
|
+
- **Works with live data**: Queries execute against current data from APIs or files
|
|
113
|
+
- **Minimal memory footprint**: Only caches what's needed for joins, not entire tables
|
|
114
|
+
- **Python-native**: Integrates seamlessly with Python code and data sources
|
|
115
|
+
|
|
45
116
|
## Features
|
|
46
117
|
|
|
47
118
|
- **Streaming execution**: Processes queries row-by-row using Python generators
|
|
@@ -185,6 +256,73 @@ for row in engine.query(query):
|
|
|
185
256
|
# {'name': 'Charlie', 'dept_name': 'Engineering'}
|
|
186
257
|
```
|
|
187
258
|
|
|
259
|
+
## Real-World Example: Joining Multiple APIs
|
|
260
|
+
|
|
261
|
+
Join data from multiple free public APIs using SQL:
|
|
262
|
+
|
|
263
|
+
```python
|
|
264
|
+
# Install: pip install streaming-sql-engine
|
|
265
|
+
import requests
|
|
266
|
+
from streaming_sql_engine import Engine
|
|
267
|
+
|
|
268
|
+
# Define API sources
|
|
269
|
+
def jsonplaceholder_users_api():
|
|
270
|
+
"""Fetch users from JSONPlaceholder API."""
|
|
271
|
+
response = requests.get("https://jsonplaceholder.typicode.com/users")
|
|
272
|
+
for user in response.json():
|
|
273
|
+
yield {
|
|
274
|
+
"user_id": user["id"],
|
|
275
|
+
"user_name": user["name"],
|
|
276
|
+
"user_email": user["email"],
|
|
277
|
+
"user_city": user["address"]["city"],
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
def jsonplaceholder_posts_api():
|
|
281
|
+
"""Fetch posts from JSONPlaceholder API."""
|
|
282
|
+
response = requests.get("https://jsonplaceholder.typicode.com/posts")
|
|
283
|
+
for post in response.json():
|
|
284
|
+
yield {
|
|
285
|
+
"post_id": post["id"],
|
|
286
|
+
"user_id": post["userId"],
|
|
287
|
+
"post_title": post["title"],
|
|
288
|
+
"post_body": post["body"][:100],
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
def rest_countries_api():
|
|
292
|
+
"""Fetch countries from REST Countries API."""
|
|
293
|
+
response = requests.get("https://restcountries.com/v3.1/all")
|
|
294
|
+
for country in response.json():
|
|
295
|
+
yield {
|
|
296
|
+
"country_code": country.get("cca2", ""),
|
|
297
|
+
"country_name": country["name"].get("common", ""),
|
|
298
|
+
"capital": country.get("capital", ["N/A"])[0] if country.get("capital") else "N/A",
|
|
299
|
+
"population": country.get("population", 0),
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
# Create engine and register sources
|
|
303
|
+
engine = Engine()
|
|
304
|
+
engine.register("users", jsonplaceholder_users_api)
|
|
305
|
+
engine.register("posts", jsonplaceholder_posts_api)
|
|
306
|
+
engine.register("countries", rest_countries_api)
|
|
307
|
+
|
|
308
|
+
# Join Users + Posts from different APIs
|
|
309
|
+
query = """
|
|
310
|
+
SELECT
|
|
311
|
+
users.user_name,
|
|
312
|
+
users.user_email,
|
|
313
|
+
posts.post_title,
|
|
314
|
+
posts.post_body
|
|
315
|
+
FROM users
|
|
316
|
+
JOIN posts ON users.user_id = posts.user_id
|
|
317
|
+
WHERE users.user_id <= 3
|
|
318
|
+
"""
|
|
319
|
+
|
|
320
|
+
for row in engine.query(query):
|
|
321
|
+
print(f"{row['user_name']} ({row['user_email']}): {row['post_title']}")
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
This example demonstrates joining data from multiple REST APIs using standard SQL syntax - no ETL, no data copying, just pure SQL joins across different data sources!
|
|
325
|
+
|
|
188
326
|
## Supported SQL Features
|
|
189
327
|
|
|
190
328
|
### SELECT
|
|
@@ -267,15 +405,6 @@ The engine raises clear exceptions for:
|
|
|
267
405
|
- **Streaming**: Results are yielded as soon as they're produced
|
|
268
406
|
- **No buffering**: Intermediate results are not fully materialized
|
|
269
407
|
|
|
270
|
-
## Documentation
|
|
271
|
-
|
|
272
|
-
- **[TECHNICAL_DOCUMENTATION.md](TECHNICAL_DOCUMENTATION.md)**: Complete technical documentation explaining architecture, algorithms, and design decisions
|
|
273
|
-
- **[DEVELOPER_GUIDE.md](DEVELOPER_GUIDE.md)**: Guide for developers who want to understand, modify, or extend the codebase
|
|
274
|
-
- **[PERFORMANCE.md](PERFORMANCE.md)**: Performance comparison with database joins and optimization tips
|
|
275
|
-
- **[MYSQL_USAGE.md](MYSQL_USAGE.md)**: MySQL-specific usage guide
|
|
276
|
-
- **[QUICK_START.md](QUICK_START.md)**: Quick start guide for new users
|
|
277
|
-
- **[INSTALLATION.md](INSTALLATION.md)**: Detailed installation instructions
|
|
278
|
-
|
|
279
408
|
## Installation from PyPI
|
|
280
409
|
|
|
281
410
|
Once published, you can install the package directly from PyPI:
|
|
@@ -286,4 +415,4 @@ pip install streaming-sql-engine
|
|
|
286
415
|
|
|
287
416
|
## License
|
|
288
417
|
|
|
289
|
-
MIT License
|
|
418
|
+
MIT License
|
|
File without changes
|
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/APACHE_DRILL_COMPARISON.md
RENAMED
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/API_JOIN_OPERATIONS.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/DUCKDB_COMPARISON.md
RENAMED
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/HOW_TO_ADD_TO_PROJECT.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/documentation/TECHNICAL_DOCUMENTATION.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/db_connector.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine/jsonl_executor.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{streaming_sql_engine-0.1.0 → streaming_sql_engine-0.1.2}/streaming_sql_engine.egg-info/requires.txt
RENAMED
|
File without changes
|
|
File without changes
|