You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+91-5Lines changed: 91 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ PyMongoSQL implements the DB API 2.0 interfaces to provide SQL-like access to Mo
28
28
-**Nested Structure Support**: Query and filter deeply nested fields and arrays within MongoDB documents using standard SQL syntax
29
29
-**SQLAlchemy Integration**: Complete ORM and Core support with dedicated MongoDB dialect
30
30
-**SQL Query Support**: SELECT statements with WHERE conditions, field selection, and aliases
31
-
-**DML Support (INSERT)**: Insert single or multiple documents using PartiQL object and bag syntax
31
+
-**DML Support**: Full support for INSERT, UPDATE, and DELETE operations using PartiQL syntax
32
32
-**Connection String Support**: MongoDB URI format for easy configuration
33
33
34
34
## Requirements
@@ -234,13 +234,97 @@ cursor.execute(
234
234
```python
235
235
# Positional parameters using ? placeholders
236
236
cursor.execute(
237
-
"INSERT INTO Music {'title': '?', 'artist': '?', 'year': '?'}",
237
+
"INSERT INTO Music {'title': ?, 'artist': ?, 'year': ?}",
238
238
["Song D", "Diana", 2020]
239
239
)
240
240
```
241
241
242
242
> Note: For INSERT, use positional parameters (`?`). Named placeholders (`:name`) are supported for SELECT queries; INSERT currently recommends `?` style.
243
243
244
+
### UPDATE Statements
245
+
246
+
PyMongoSQL supports updating documents in MongoDB collections using standard SQL UPDATE syntax.
247
+
248
+
-**Update All Documents**
249
+
250
+
```python
251
+
cursor.execute("UPDATE Music SET available = false")
252
+
```
253
+
254
+
-**Update Multiple Fields**
255
+
256
+
```python
257
+
cursor.execute(
258
+
"UPDATE Music SET price = 19.99, available = true WHERE artist = 'Alice'"
259
+
)
260
+
```
261
+
262
+
-**Update with Comparisons and Logical Operators**
263
+
264
+
```python
265
+
cursor.execute(
266
+
"UPDATE Music SET price = 9.99 WHERE year = 2020 AND stock > 5"
267
+
)
268
+
```
269
+
270
+
-**Parameterized UPDATE**
271
+
272
+
```python
273
+
# Positional parameters using ? placeholders
274
+
cursor.execute(
275
+
"UPDATE Music SET price = ?, stock = ? WHERE artist = ?",
276
+
[24.99, 50, "Bob"]
277
+
)
278
+
```
279
+
280
+
-**Update Nested Fields**
281
+
282
+
```python
283
+
cursor.execute("UPDATE Music SET details.publisher = 'XYZ Records' WHERE title = 'Song A'")
284
+
```
285
+
286
+
-**Check Updated Row Count**
287
+
288
+
```python
289
+
cursor.execute("UPDATE Music SET available = false WHERE year = 2020")
290
+
print(f"Updated {cursor.rowcount} documents")
291
+
```
292
+
293
+
### DELETE Statements
294
+
295
+
PyMongoSQL supports deleting documents from MongoDB collections using standard SQL DELETE syntax.
296
+
297
+
-**Delete All Documents**
298
+
299
+
```python
300
+
cursor.execute("DELETE FROM Music")
301
+
```
302
+
303
+
-**Delete with Logical Operators**
304
+
305
+
```python
306
+
cursor.execute(
307
+
"DELETE FROM Music WHERE year = 2019 AND available = false"
308
+
)
309
+
```
310
+
311
+
-**Parameterized DELETE**
312
+
313
+
```python
314
+
# Positional parameters using ? placeholders
315
+
cursor.execute(
316
+
"DELETE FROM Music WHERE artist = ? AND year < ?",
317
+
["Charlie", 2021]
318
+
)
319
+
```
320
+
321
+
-**Check Deleted Row Count**
322
+
323
+
```python
324
+
cursor.execute("DELETE FROM Music WHERE available = false")
325
+
print(f"Deleted {cursor.rowcount} documents")
326
+
```
327
+
244
328
## Apache Superset Integration
245
329
246
330
PyMongoSQL can be used as a database driver in Apache Superset for querying and visualizing MongoDB data:
@@ -264,14 +348,16 @@ This allows seamless integration between MongoDB data and Superset's BI capabili
264
348
265
349
<h2style="color: red;">Limitations & Roadmap</h2>
266
350
267
-
**Note**: PyMongoSQL focuses on Data Query Language (DQL) operations and selective DML support. The following SQL features are **not yet supported** but are planned for future releases:
351
+
**Note**: PyMongoSQL currently supports DQL (Data Query Language) and DML (Data Manipulation Language) operations. The following SQL features are **not yet supported** but are planned for future releases:
0 commit comments