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
+33-2Lines changed: 33 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,6 +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
32
-**Connection String Support**: MongoDB URI format for easy configuration
32
33
33
34
## Requirements
@@ -210,6 +211,36 @@ Parameters are substituted into the MongoDB filter during execution, providing p
210
211
- LIMIT: `LIMIT 10`
211
212
- Combined: `ORDER BY created_at DESC LIMIT 5`
212
213
214
+
### INSERT Statements
215
+
216
+
PyMongoSQL supports inserting documents into MongoDB collections using PartiQL-style object and bag literals.
217
+
218
+
-**Single Document**
219
+
220
+
```python
221
+
cursor.execute("INSERT INTO Music {'title': 'Song A', 'artist': 'Alice', 'year': 2021}")
222
+
```
223
+
224
+
-**Multiple Documents (Bag Syntax)**
225
+
226
+
```python
227
+
cursor.execute(
228
+
"INSERT INTO Music << {'title': 'Song B', 'artist': 'Bob'}, {'title': 'Song C', 'artist': 'Charlie'} >>"
229
+
)
230
+
```
231
+
232
+
-**Parameterized INSERT (qmark placeholders)**
233
+
234
+
```python
235
+
# Positional parameters using ? placeholders
236
+
cursor.execute(
237
+
"INSERT INTO Music {'title': '?', 'artist': '?', 'year': '?'}",
238
+
["Song D", "Diana", 2020]
239
+
)
240
+
```
241
+
242
+
> Note: For INSERT, use positional parameters (`?`). Named placeholders (`:name`) are supported for SELECT queries; INSERT currently recommends `?` style.
243
+
213
244
## Apache Superset Integration
214
245
215
246
PyMongoSQL can be used as a database driver in Apache Superset for querying and visualizing MongoDB data:
@@ -233,10 +264,10 @@ This allows seamless integration between MongoDB data and Superset's BI capabili
233
264
234
265
<h2style="color: red;">Limitations & Roadmap</h2>
235
266
236
-
**Note**: Currently PyMongoSQL focuses on Data Query Language (DQL) operations. The following SQL features are **not yet supported** but are planned for future releases:
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:
0 commit comments