crondb-driver 1.0.0__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.
- crondb_driver-1.0.0/PKG-INFO +34 -0
- crondb_driver-1.0.0/README.md +16 -0
- crondb_driver-1.0.0/crondb/__init__.py +0 -0
- crondb_driver-1.0.0/crondb/crondb.py +57 -0
- crondb_driver-1.0.0/crondb/test_crondb.py +49 -0
- crondb_driver-1.0.0/crondb_driver.egg-info/PKG-INFO +34 -0
- crondb_driver-1.0.0/crondb_driver.egg-info/SOURCES.txt +10 -0
- crondb_driver-1.0.0/crondb_driver.egg-info/dependency_links.txt +1 -0
- crondb_driver-1.0.0/crondb_driver.egg-info/requires.txt +1 -0
- crondb_driver-1.0.0/crondb_driver.egg-info/top_level.txt +1 -0
- crondb_driver-1.0.0/setup.cfg +4 -0
- crondb_driver-1.0.0/setup.py +22 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: crondb-driver
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The official Python ORM and connection driver for the CronDB temporal database.
|
|
5
|
+
Author: Michael Tal
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Requires-Python: >=3.6
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: requests
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: classifier
|
|
13
|
+
Dynamic: description
|
|
14
|
+
Dynamic: description-content-type
|
|
15
|
+
Dynamic: requires-dist
|
|
16
|
+
Dynamic: requires-python
|
|
17
|
+
Dynamic: summary
|
|
18
|
+
|
|
19
|
+
# CronDB Python SDK
|
|
20
|
+
|
|
21
|
+
The official Object-Relational Mapping (ORM) and connection driver for **CronDB**, a high-performance, temporal C++ database engine.
|
|
22
|
+
|
|
23
|
+
Traditional Python architectures force you to build "split-brain" systems to handle time-based events: storing the data in a standard database while pushing the countdown timers to an external task queue or background worker system.
|
|
24
|
+
|
|
25
|
+
**CronDB unifies state and time.** You inject finite-state-machine (FSM) timers directly into your database rows. When a state naturally expires, the C++ engine's asynchronous background threads instantly push a webhook directly to your backend server.
|
|
26
|
+
|
|
27
|
+
No polling. No background workers. No external queues. Just one unified temporal engine.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 📦 Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install crondb-driver
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# CronDB Python SDK
|
|
2
|
+
|
|
3
|
+
The official Object-Relational Mapping (ORM) and connection driver for **CronDB**, a high-performance, temporal C++ database engine.
|
|
4
|
+
|
|
5
|
+
Traditional Python architectures force you to build "split-brain" systems to handle time-based events: storing the data in a standard database while pushing the countdown timers to an external task queue or background worker system.
|
|
6
|
+
|
|
7
|
+
**CronDB unifies state and time.** You inject finite-state-machine (FSM) timers directly into your database rows. When a state naturally expires, the C++ engine's asynchronous background threads instantly push a webhook directly to your backend server.
|
|
8
|
+
|
|
9
|
+
No polling. No background workers. No external queues. Just one unified temporal engine.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 📦 Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install crondb-driver
|
|
File without changes
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
class CronDB:
|
|
5
|
+
def __init__(self, host='127.0.0.1', port=8080):
|
|
6
|
+
self.url = f"http://{host}:{port}/query"
|
|
7
|
+
# Connection pooling to prevent overhead
|
|
8
|
+
self.session = requests.Session()
|
|
9
|
+
|
|
10
|
+
def query(self, sql_string):
|
|
11
|
+
"""Sends raw SQL text to the C++ engine"""
|
|
12
|
+
headers = {'Content-Type': 'text/plain'}
|
|
13
|
+
try:
|
|
14
|
+
response = self.session.post(self.url, data=sql_string, headers=headers)
|
|
15
|
+
# Try to return JSON if the C++ engine sent it
|
|
16
|
+
try:
|
|
17
|
+
return response.json()
|
|
18
|
+
except:
|
|
19
|
+
return response.text
|
|
20
|
+
except Exception as e:
|
|
21
|
+
return {"success": False, "message": str(e)}
|
|
22
|
+
|
|
23
|
+
def _format(self, val):
|
|
24
|
+
"""Translates Python types to CronDB SQL types"""
|
|
25
|
+
if isinstance(val, bool):
|
|
26
|
+
return str(val).lower() # True -> true
|
|
27
|
+
if isinstance(val, (int, float)):
|
|
28
|
+
return str(val)
|
|
29
|
+
if isinstance(val, str):
|
|
30
|
+
# Check for Temporal FSM syntax ( ... --> ... )
|
|
31
|
+
if val.strip().startswith('(') and '-->' in val:
|
|
32
|
+
return val
|
|
33
|
+
return f"'{val}'"
|
|
34
|
+
return str(val)
|
|
35
|
+
|
|
36
|
+
def insert(self, table, data):
|
|
37
|
+
fields = " ".join([f"{k}={self._format(v)}" for k, v in data.items()])
|
|
38
|
+
return self.query(f"INSERT INTO {table} {fields}")
|
|
39
|
+
|
|
40
|
+
def select(self, table, where=None):
|
|
41
|
+
sql = f"SELECT * FROM {table}"
|
|
42
|
+
if where:
|
|
43
|
+
sql += f" WHERE {where}"
|
|
44
|
+
return self.query(sql)
|
|
45
|
+
|
|
46
|
+
def update(self, table, data, where):
|
|
47
|
+
fields = " ".join([f"{k}={self._format(v)}" for k, v in data.items()])
|
|
48
|
+
return self.query(f"UPDATE {table} SET {fields} WHERE {where}")
|
|
49
|
+
|
|
50
|
+
def delete(self, table, where):
|
|
51
|
+
return self.query(f"DELETE FROM {table} WHERE {where}")
|
|
52
|
+
|
|
53
|
+
def listen(self, table, col, url, where=None):
|
|
54
|
+
sql = f"LISTEN {table} . {col} --> '{url}'"
|
|
55
|
+
if where:
|
|
56
|
+
sql += f" WHERE {where}"
|
|
57
|
+
return self.query(sql)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from crondb import CronDB
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
db = CronDB()
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def run_test():
|
|
8
|
+
print("--- Starting CronDB Python SDK Test ---")
|
|
9
|
+
|
|
10
|
+
# 1. Clean start
|
|
11
|
+
db.query("DROP TABLE robots")
|
|
12
|
+
|
|
13
|
+
# 2. CREATE TABLE (Manual Query)
|
|
14
|
+
print("\n[1] Creating Table...")
|
|
15
|
+
print(db.query("CREATE TABLE robots rid ApexInt name string status string 3"))
|
|
16
|
+
|
|
17
|
+
# 3. INSERT via ORM
|
|
18
|
+
print("\n[2] Inserting Data (Standard & Temporal)...")
|
|
19
|
+
db.insert('robots', {'name': 'R2D2', 'status': 'Idle'})
|
|
20
|
+
db.insert('robots', {
|
|
21
|
+
'name': 'Terminator',
|
|
22
|
+
'status': "('Searching' --> 'Found' @ 3 s)"
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
# 4. SELECT via ORM
|
|
26
|
+
print("\n[3] Reading Data...")
|
|
27
|
+
res = db.select('robots')
|
|
28
|
+
print(f"Rows found: {res.get('rows_affected')}")
|
|
29
|
+
for row in res.get('data', []):
|
|
30
|
+
print(f" -> {row}")
|
|
31
|
+
|
|
32
|
+
# 5. UPDATE via ORM
|
|
33
|
+
print("\n[4] Updating R2D2...")
|
|
34
|
+
db.update('robots', {'status': 'Beeping'}, "name = 'R2D2'")
|
|
35
|
+
|
|
36
|
+
# 6. WAIT for FSM to fire
|
|
37
|
+
print("\n[5] Waiting 4 seconds for Terminator to find target...")
|
|
38
|
+
time.sleep(3)
|
|
39
|
+
|
|
40
|
+
# 7. FINAL VERIFICATION
|
|
41
|
+
print("\n[6] Final State Check...")
|
|
42
|
+
final = db.select('robots', "name = 'Terminator'")
|
|
43
|
+
print(f"Terminator Status: {final['data'][0]['status']}")
|
|
44
|
+
|
|
45
|
+
print("\n--- Test Complete ---")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
if __name__ == "__main__":
|
|
49
|
+
run_test()
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: crondb-driver
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The official Python ORM and connection driver for the CronDB temporal database.
|
|
5
|
+
Author: Michael Tal
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Operating System :: OS Independent
|
|
8
|
+
Requires-Python: >=3.6
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: requests
|
|
11
|
+
Dynamic: author
|
|
12
|
+
Dynamic: classifier
|
|
13
|
+
Dynamic: description
|
|
14
|
+
Dynamic: description-content-type
|
|
15
|
+
Dynamic: requires-dist
|
|
16
|
+
Dynamic: requires-python
|
|
17
|
+
Dynamic: summary
|
|
18
|
+
|
|
19
|
+
# CronDB Python SDK
|
|
20
|
+
|
|
21
|
+
The official Object-Relational Mapping (ORM) and connection driver for **CronDB**, a high-performance, temporal C++ database engine.
|
|
22
|
+
|
|
23
|
+
Traditional Python architectures force you to build "split-brain" systems to handle time-based events: storing the data in a standard database while pushing the countdown timers to an external task queue or background worker system.
|
|
24
|
+
|
|
25
|
+
**CronDB unifies state and time.** You inject finite-state-machine (FSM) timers directly into your database rows. When a state naturally expires, the C++ engine's asynchronous background threads instantly push a webhook directly to your backend server.
|
|
26
|
+
|
|
27
|
+
No polling. No background workers. No external queues. Just one unified temporal engine.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 📦 Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install crondb-driver
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
crondb/__init__.py
|
|
4
|
+
crondb/crondb.py
|
|
5
|
+
crondb/test_crondb.py
|
|
6
|
+
crondb_driver.egg-info/PKG-INFO
|
|
7
|
+
crondb_driver.egg-info/SOURCES.txt
|
|
8
|
+
crondb_driver.egg-info/dependency_links.txt
|
|
9
|
+
crondb_driver.egg-info/requires.txt
|
|
10
|
+
crondb_driver.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
crondb
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="crondb-driver", # The name people will pip install
|
|
8
|
+
version="1.0.0",
|
|
9
|
+
author="Michael Tal",
|
|
10
|
+
description="The official Python ORM and connection driver for the CronDB temporal database.",
|
|
11
|
+
long_description=long_description,
|
|
12
|
+
long_description_content_type="text/markdown",
|
|
13
|
+
packages=find_packages(),
|
|
14
|
+
install_requires=[
|
|
15
|
+
"requests", # Tells pip to auto-install the requests library for the user
|
|
16
|
+
],
|
|
17
|
+
classifiers=[
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
],
|
|
21
|
+
python_requires='>=3.6',
|
|
22
|
+
)
|