pyflashdb 1.0.2__tar.gz → 1.0.4__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.
Files changed (32) hide show
  1. pyflashdb-1.0.4/LICENSE +21 -0
  2. pyflashdb-1.0.4/MANIFEST.in +6 -0
  3. pyflashdb-1.0.4/PKG-INFO +236 -0
  4. pyflashdb-1.0.4/README.md +222 -0
  5. pyflashdb-1.0.4/flash/__init__.py +33 -0
  6. {pyflashdb-1.0.2 → pyflashdb-1.0.4}/flash/adapters/mongo_adapter.py +92 -92
  7. {pyflashdb-1.0.2 → pyflashdb-1.0.4}/flash/adapters/mysql_adapter.py +77 -57
  8. pyflashdb-1.0.4/flash/adapters/postgres_adapter.py +258 -0
  9. pyflashdb-1.0.4/flash/core.py +323 -0
  10. pyflashdb-1.0.4/flash/exceptions.py +48 -0
  11. pyflashdb-1.0.4/flash/filters.py +217 -0
  12. pyflashdb-1.0.4/flash/triggers.py +191 -0
  13. pyflashdb-1.0.4/pyflashdb.egg-info/PKG-INFO +236 -0
  14. {pyflashdb-1.0.2 → pyflashdb-1.0.4}/pyflashdb.egg-info/SOURCES.txt +3 -1
  15. pyflashdb-1.0.4/pyflashdb.egg-info/top_level.txt +3 -0
  16. pyflashdb-1.0.4/pyproject.toml +17 -0
  17. pyflashdb-1.0.4/setup.py +40 -0
  18. pyflashdb-1.0.2/PKG-INFO +0 -365
  19. pyflashdb-1.0.2/README.md +0 -333
  20. pyflashdb-1.0.2/flash/__init__.py +0 -10
  21. pyflashdb-1.0.2/flash/adapters/postgres_adapter.py +0 -226
  22. pyflashdb-1.0.2/flash/core.py +0 -306
  23. pyflashdb-1.0.2/flash/exceptions.py +0 -33
  24. pyflashdb-1.0.2/flash/filters.py +0 -140
  25. pyflashdb-1.0.2/flash/triggers.py +0 -148
  26. pyflashdb-1.0.2/pyflashdb.egg-info/PKG-INFO +0 -365
  27. pyflashdb-1.0.2/pyflashdb.egg-info/requires.txt +0 -14
  28. pyflashdb-1.0.2/pyflashdb.egg-info/top_level.txt +0 -1
  29. pyflashdb-1.0.2/setup.py +0 -34
  30. {pyflashdb-1.0.2 → pyflashdb-1.0.4}/flash/adapters/__init__.py +0 -0
  31. {pyflashdb-1.0.2 → pyflashdb-1.0.4}/pyflashdb.egg-info/dependency_links.txt +0 -0
  32. {pyflashdb-1.0.2 → pyflashdb-1.0.4}/setup.cfg +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Aman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ exclude myenv/*
2
+ exclude venv/*
3
+ prune myenv
4
+ prune venv
5
+ global-exclude __pycache__/*
6
+ global-exclude *.pyc
@@ -0,0 +1,236 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyflashdb
3
+ Version: 1.0.4
4
+ Summary: Unified database interface for MySQL, PostgreSQL, and MongoDB
5
+ Home-page: https://github.com/AmanDev17/pyflashdb
6
+ Author: Aman Singh
7
+ License: MIT
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Dynamic: home-page
12
+ Dynamic: license-file
13
+ Dynamic: requires-python
14
+
15
+ <div align="center">
16
+
17
+ <br/>
18
+
19
+ # ⚡ pyflashdb
20
+
21
+ **Stop writing database code three times.**
22
+
23
+ [![PyPI](https://img.shields.io/badge/pypi-v1.0.4-E94560?style=flat-square\&logo=pypi\&logoColor=white)](https://pypi.org/project/pyflashdb/)
24
+ [![Python](https://img.shields.io/badge/python-3.8%2B-3776AB?style=flat-square\&logo=python\&logoColor=white)](https://www.python.org/)
25
+ [![License: MIT](https://img.shields.io/badge/license-MIT-10B981?style=flat-square)](LICENSE)
26
+ [![MySQL](https://img.shields.io/badge/MySQL-supported-00758F?style=flat-square\&logo=mysql\&logoColor=white)](https://www.mysql.com/)
27
+ [![PostgreSQL](https://img.shields.io/badge/PostgreSQL-supported-336791?style=flat-square\&logo=postgresql\&logoColor=white)](https://www.postgresql.org/)
28
+ [![MongoDB](https://img.shields.io/badge/MongoDB-supported-3D8B37?style=flat-square\&logo=mongodb\&logoColor=white)](https://www.mongodb.com/)
29
+
30
+ <br/>
31
+
32
+ </div>
33
+
34
+ ---
35
+
36
+ ## What is pyflashdb?
37
+
38
+ pyflashdb is a Python library that lets you talk to **MySQL**, **PostgreSQL**, and **MongoDB** using the exact same code.
39
+
40
+ You write one line. It works on all three databases. No SQL knowledge required. No driver switching. No boilerplate.
41
+
42
+ ```python
43
+ from flash import FlashDB
44
+
45
+ flash = FlashDB("mysql", config) # change to "postgres" or "mongodb" — nothing else changes
46
+
47
+ flash.add("users", {"name": "Alice", "age": 25}) # insert
48
+ flash.where("users", {"age": {">": 18}}) # filter
49
+ flash.update("users", {"name": "Alice"}, {"age": 26}) # update
50
+ flash.delete("users", {"name": "Alice"}) # delete
51
+ ```
52
+
53
+ That's it. Same four lines work on MySQL, PostgreSQL, and MongoDB.
54
+
55
+ ---
56
+
57
+ ## The Problem It Solves
58
+
59
+ Most projects start with one database and grow to need another. Or your team uses MySQL locally but PostgreSQL in production. Or you want MongoDB for one feature and SQL for another.
60
+
61
+ Every time you switch databases, you rewrite your query code — because each database has a completely different API.
62
+
63
+ **Without pyflashdb — three different APIs to learn and maintain:**
64
+
65
+ ```python
66
+ # MySQL
67
+ cursor.execute("INSERT INTO users (name, age) VALUES (%s, %s)", ("Alice", 25))
68
+ conn.commit()
69
+
70
+ # PostgreSQL — different driver, slightly different syntax
71
+ cursor.execute('INSERT INTO "users" (name, age) VALUES (%s, %s) RETURNING id', ("Alice", 25))
72
+
73
+ # MongoDB — completely different world
74
+ db["users"].insert_one({"name": "Alice", "age": 25})
75
+ ```
76
+
77
+ **With pyflashdb — one line, any database:**
78
+
79
+ ```python
80
+ flash.add("users", {"name": "Alice", "age": 25})
81
+ ```
82
+
83
+ Switch your database by changing one word. Your application code stays exactly the same.
84
+
85
+ ---
86
+
87
+ ## Install
88
+
89
+ ```bash
90
+ # Pick the database you use
91
+ pip install pyflashdb[mysql] # MySQL
92
+ pip install pyflashdb[postgres] # PostgreSQL
93
+ pip install pyflashdb[mongodb] # MongoDB
94
+ pip install pyflashdb[all] # All three
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Quick Example — A Complete User System in 20 Lines
100
+
101
+ ```python
102
+ from flash import FlashDB
103
+
104
+ # Connect — swap "mysql" for "postgres" or "mongodb" to change databases
105
+ flash = FlashDB("mysql", {
106
+ "host": "localhost",
107
+ "user": "root",
108
+ "password": "your_password",
109
+ "database": "myapp"
110
+ })
111
+
112
+ # Create the table
113
+ flash.create_table("users", {
114
+ "id": "int",
115
+ "name": "str",
116
+ "email": "str",
117
+ "age": "int",
118
+ })
119
+
120
+ # Insert
121
+ flash.add("users", {"name": "Alice", "email": "alice@example.com", "age": 25})
122
+ flash.add("users", {"name": "Bob", "email": "bob@example.com", "age": 17})
123
+
124
+ # Read
125
+ all_users = flash.all("users") # everyone
126
+ adults = flash.where("users", {"age": {">": 18}}) # filtered
127
+ one_user = flash.find_one("users", {"name": "Alice"}) # single record
128
+ page = flash.paginate("users", page=1, size=10) # paginated
129
+
130
+ # Update
131
+ flash.update("users", {"name": "Alice"}, {"age": 26})
132
+
133
+ # Delete
134
+ flash.delete("users", {"name": "Bob"})
135
+
136
+ flash.close()
137
+ ```
138
+
139
+ ---
140
+
141
+ ## Core Features
142
+
143
+ ### Everything you need for database work
144
+
145
+ | Feature | What it does |
146
+ | --------------------------- | --------------------------------------------------------- |
147
+ | `add()` | Insert one record, returns the new ID |
148
+ | `bulk_insert()` | Insert many records in one call |
149
+ | `all()` | Fetch every record from a table |
150
+ | `where()` | Fetch records matching a filter |
151
+ | `select()` | Full query — filter, sort, limit, offset, specific fields |
152
+ | `find_one()` | Get the first match, or None |
153
+ | `count()` | Count records without fetching them |
154
+ | `paginate()` | Built-in pagination with total count |
155
+ | `update()` | Update matching records |
156
+ | `delete()` | Delete matching records |
157
+ | `create_table()` | Create a table or collection |
158
+ | `drop_table()` | Drop a table or collection |
159
+ | `truncate()` | Clear all rows, keep the structure |
160
+ | `raw()` | Run a raw SQL query or MongoDB command |
161
+ | `begin / commit / rollback` | Full transaction support |
162
+
163
+ ### Smart filter syntax — write once, works everywhere
164
+
165
+ ```python
166
+ flash.where("users", {"age": {">": 18}})
167
+ flash.where("users", {"age": {">=": 18, "<=": 65}})
168
+ flash.where("users", {"role": {"in": ["admin", "mod"]}})
169
+ flash.where("users", {"email": {"like": "%@gmail.com"}})
170
+ flash.where("users", {"status": {"!=": "banned"}})
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Trigger hooks — observe any operation
176
+
177
+ ```python
178
+ @flash.before_insert("users")
179
+ def validate(data):
180
+ if not data.get("email"):
181
+ raise ValueError("Email is required")
182
+
183
+ @flash.after_insert("users")
184
+ def on_created(data, result):
185
+ print(f"New user created — ID: {result}")
186
+
187
+ @flash.after_delete("orders")
188
+ def on_deleted(filters, count):
189
+ print(f"Deleted {count} order(s)")
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Transactions — atomic operations
195
+
196
+ ```python
197
+ flash.begin()
198
+ try:
199
+ flash.update("accounts", {"user_id": 1}, {"balance": 400})
200
+ flash.update("accounts", {"user_id": 2}, {"balance": 600})
201
+ flash.commit()
202
+ except Exception as e:
203
+ flash.rollback()
204
+ ```
205
+
206
+ ---
207
+
208
+ ## How pyflashdb Compares
209
+
210
+ | | pyflashdb | SQLAlchemy | Django ORM | Raw drivers |
211
+ | ----------------------- | :-------: | :--------: | :--------: | :---------: |
212
+ | Works on MySQL | ✅ | ✅ | ✅ | ✅ |
213
+ | Works on PostgreSQL | ✅ | ✅ | ✅ | ✅ |
214
+ | Works on MongoDB | ✅ | ❌ | ❌ | ✅ |
215
+ | Same API across all DBs | ✅ | ❌ | ❌ | ❌ |
216
+
217
+ ---
218
+
219
+ ## Links
220
+
221
+ * **PyPI:** https://pypi.org/project/pyflashdb/
222
+ * **Issues:** https://github.com/AmanDev17/pyflashdb/issues
223
+
224
+ ---
225
+
226
+ ## Documentation
227
+
228
+ 📄 [Full Documentation (PDF)](https://github.com/AmanDev17/pyflashdb/blob/main/pyflashdb_v_1.0.4_README.pdf)
229
+
230
+ <div align="center">
231
+
232
+ **pyflashdb v1.0.4** · MIT License · Python 3.8+
233
+
234
+ *One API. Any database. Zero boilerplate.*
235
+
236
+ </div>
@@ -0,0 +1,222 @@
1
+ <div align="center">
2
+
3
+ <br/>
4
+
5
+ # ⚡ pyflashdb
6
+
7
+ **Stop writing database code three times.**
8
+
9
+ [![PyPI](https://img.shields.io/badge/pypi-v1.0.4-E94560?style=flat-square\&logo=pypi\&logoColor=white)](https://pypi.org/project/pyflashdb/)
10
+ [![Python](https://img.shields.io/badge/python-3.8%2B-3776AB?style=flat-square\&logo=python\&logoColor=white)](https://www.python.org/)
11
+ [![License: MIT](https://img.shields.io/badge/license-MIT-10B981?style=flat-square)](LICENSE)
12
+ [![MySQL](https://img.shields.io/badge/MySQL-supported-00758F?style=flat-square\&logo=mysql\&logoColor=white)](https://www.mysql.com/)
13
+ [![PostgreSQL](https://img.shields.io/badge/PostgreSQL-supported-336791?style=flat-square\&logo=postgresql\&logoColor=white)](https://www.postgresql.org/)
14
+ [![MongoDB](https://img.shields.io/badge/MongoDB-supported-3D8B37?style=flat-square\&logo=mongodb\&logoColor=white)](https://www.mongodb.com/)
15
+
16
+ <br/>
17
+
18
+ </div>
19
+
20
+ ---
21
+
22
+ ## What is pyflashdb?
23
+
24
+ pyflashdb is a Python library that lets you talk to **MySQL**, **PostgreSQL**, and **MongoDB** using the exact same code.
25
+
26
+ You write one line. It works on all three databases. No SQL knowledge required. No driver switching. No boilerplate.
27
+
28
+ ```python
29
+ from flash import FlashDB
30
+
31
+ flash = FlashDB("mysql", config) # change to "postgres" or "mongodb" — nothing else changes
32
+
33
+ flash.add("users", {"name": "Alice", "age": 25}) # insert
34
+ flash.where("users", {"age": {">": 18}}) # filter
35
+ flash.update("users", {"name": "Alice"}, {"age": 26}) # update
36
+ flash.delete("users", {"name": "Alice"}) # delete
37
+ ```
38
+
39
+ That's it. Same four lines work on MySQL, PostgreSQL, and MongoDB.
40
+
41
+ ---
42
+
43
+ ## The Problem It Solves
44
+
45
+ Most projects start with one database and grow to need another. Or your team uses MySQL locally but PostgreSQL in production. Or you want MongoDB for one feature and SQL for another.
46
+
47
+ Every time you switch databases, you rewrite your query code — because each database has a completely different API.
48
+
49
+ **Without pyflashdb — three different APIs to learn and maintain:**
50
+
51
+ ```python
52
+ # MySQL
53
+ cursor.execute("INSERT INTO users (name, age) VALUES (%s, %s)", ("Alice", 25))
54
+ conn.commit()
55
+
56
+ # PostgreSQL — different driver, slightly different syntax
57
+ cursor.execute('INSERT INTO "users" (name, age) VALUES (%s, %s) RETURNING id', ("Alice", 25))
58
+
59
+ # MongoDB — completely different world
60
+ db["users"].insert_one({"name": "Alice", "age": 25})
61
+ ```
62
+
63
+ **With pyflashdb — one line, any database:**
64
+
65
+ ```python
66
+ flash.add("users", {"name": "Alice", "age": 25})
67
+ ```
68
+
69
+ Switch your database by changing one word. Your application code stays exactly the same.
70
+
71
+ ---
72
+
73
+ ## Install
74
+
75
+ ```bash
76
+ # Pick the database you use
77
+ pip install pyflashdb[mysql] # MySQL
78
+ pip install pyflashdb[postgres] # PostgreSQL
79
+ pip install pyflashdb[mongodb] # MongoDB
80
+ pip install pyflashdb[all] # All three
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Quick Example — A Complete User System in 20 Lines
86
+
87
+ ```python
88
+ from flash import FlashDB
89
+
90
+ # Connect — swap "mysql" for "postgres" or "mongodb" to change databases
91
+ flash = FlashDB("mysql", {
92
+ "host": "localhost",
93
+ "user": "root",
94
+ "password": "your_password",
95
+ "database": "myapp"
96
+ })
97
+
98
+ # Create the table
99
+ flash.create_table("users", {
100
+ "id": "int",
101
+ "name": "str",
102
+ "email": "str",
103
+ "age": "int",
104
+ })
105
+
106
+ # Insert
107
+ flash.add("users", {"name": "Alice", "email": "alice@example.com", "age": 25})
108
+ flash.add("users", {"name": "Bob", "email": "bob@example.com", "age": 17})
109
+
110
+ # Read
111
+ all_users = flash.all("users") # everyone
112
+ adults = flash.where("users", {"age": {">": 18}}) # filtered
113
+ one_user = flash.find_one("users", {"name": "Alice"}) # single record
114
+ page = flash.paginate("users", page=1, size=10) # paginated
115
+
116
+ # Update
117
+ flash.update("users", {"name": "Alice"}, {"age": 26})
118
+
119
+ # Delete
120
+ flash.delete("users", {"name": "Bob"})
121
+
122
+ flash.close()
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Core Features
128
+
129
+ ### Everything you need for database work
130
+
131
+ | Feature | What it does |
132
+ | --------------------------- | --------------------------------------------------------- |
133
+ | `add()` | Insert one record, returns the new ID |
134
+ | `bulk_insert()` | Insert many records in one call |
135
+ | `all()` | Fetch every record from a table |
136
+ | `where()` | Fetch records matching a filter |
137
+ | `select()` | Full query — filter, sort, limit, offset, specific fields |
138
+ | `find_one()` | Get the first match, or None |
139
+ | `count()` | Count records without fetching them |
140
+ | `paginate()` | Built-in pagination with total count |
141
+ | `update()` | Update matching records |
142
+ | `delete()` | Delete matching records |
143
+ | `create_table()` | Create a table or collection |
144
+ | `drop_table()` | Drop a table or collection |
145
+ | `truncate()` | Clear all rows, keep the structure |
146
+ | `raw()` | Run a raw SQL query or MongoDB command |
147
+ | `begin / commit / rollback` | Full transaction support |
148
+
149
+ ### Smart filter syntax — write once, works everywhere
150
+
151
+ ```python
152
+ flash.where("users", {"age": {">": 18}})
153
+ flash.where("users", {"age": {">=": 18, "<=": 65}})
154
+ flash.where("users", {"role": {"in": ["admin", "mod"]}})
155
+ flash.where("users", {"email": {"like": "%@gmail.com"}})
156
+ flash.where("users", {"status": {"!=": "banned"}})
157
+ ```
158
+
159
+ ---
160
+
161
+ ## Trigger hooks — observe any operation
162
+
163
+ ```python
164
+ @flash.before_insert("users")
165
+ def validate(data):
166
+ if not data.get("email"):
167
+ raise ValueError("Email is required")
168
+
169
+ @flash.after_insert("users")
170
+ def on_created(data, result):
171
+ print(f"New user created — ID: {result}")
172
+
173
+ @flash.after_delete("orders")
174
+ def on_deleted(filters, count):
175
+ print(f"Deleted {count} order(s)")
176
+ ```
177
+
178
+ ---
179
+
180
+ ## Transactions — atomic operations
181
+
182
+ ```python
183
+ flash.begin()
184
+ try:
185
+ flash.update("accounts", {"user_id": 1}, {"balance": 400})
186
+ flash.update("accounts", {"user_id": 2}, {"balance": 600})
187
+ flash.commit()
188
+ except Exception as e:
189
+ flash.rollback()
190
+ ```
191
+
192
+ ---
193
+
194
+ ## How pyflashdb Compares
195
+
196
+ | | pyflashdb | SQLAlchemy | Django ORM | Raw drivers |
197
+ | ----------------------- | :-------: | :--------: | :--------: | :---------: |
198
+ | Works on MySQL | ✅ | ✅ | ✅ | ✅ |
199
+ | Works on PostgreSQL | ✅ | ✅ | ✅ | ✅ |
200
+ | Works on MongoDB | ✅ | ❌ | ❌ | ✅ |
201
+ | Same API across all DBs | ✅ | ❌ | ❌ | ❌ |
202
+
203
+ ---
204
+
205
+ ## Links
206
+
207
+ * **PyPI:** https://pypi.org/project/pyflashdb/
208
+ * **Issues:** https://github.com/AmanDev17/pyflashdb/issues
209
+
210
+ ---
211
+
212
+ ## Documentation
213
+
214
+ 📄 [Full Documentation (PDF)](https://github.com/AmanDev17/pyflashdb/blob/main/pyflashdb_v_1.0.4_README.pdf)
215
+
216
+ <div align="center">
217
+
218
+ **pyflashdb v1.0.4** · MIT License · Python 3.8+
219
+
220
+ *One API. Any database. Zero boilerplate.*
221
+
222
+ </div>
@@ -0,0 +1,33 @@
1
+ """
2
+ pyflashdb — A unified database interface for MySQL, PostgreSQL, and MongoDB.
3
+
4
+ Usage:
5
+ from flash import FlashDB
6
+ flash = FlashDB("mysql", config)
7
+ """
8
+
9
+ from .core import FlashDB
10
+ from .exceptions import (
11
+ FlashError,
12
+ FlashConnectionError, # renamed — does NOT shadow Python's built-in ConnectionError
13
+ QueryError,
14
+ TransactionError,
15
+ SchemaError,
16
+ UnsupportedDatabaseError,
17
+ )
18
+
19
+ __version__ = "1.0.4"
20
+ __author__ = "Aman Singh"
21
+ __credits__ = "Inspired by Komal Verma"
22
+ __license__ = "MIT"
23
+
24
+ __all__ = [
25
+ "FlashDB",
26
+ # Exceptions — import these, not Python's built-ins
27
+ "FlashError",
28
+ "FlashConnectionError",
29
+ "QueryError",
30
+ "TransactionError",
31
+ "SchemaError",
32
+ "UnsupportedDatabaseError",
33
+ ]