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
PyMongoSQL provides two cursor types for different result formats:
131
+
132
+
**Cursor** (default) - Returns results as tuples:
133
+
```python
121
134
cursor = connection.cursor()
135
+
cursor.execute('SELECT name, email FROM users')
136
+
row = cursor.fetchone()
137
+
print(row[0]) # Access by index
138
+
```
139
+
140
+
**DictCursor** - Returns results as dict:
141
+
```python
142
+
from pymongosql.cursor import DictCursor
122
143
123
-
# Parameterized queries for security
124
-
min_age =18
125
-
status ='active'
126
-
127
-
cursor.execute('''
128
-
SELECT name, email, created_at
129
-
FROM users
130
-
WHERE age >= ? AND status = ?
131
-
''', [min_age, status])
132
-
133
-
users = cursor.fetchmany(5) # Fetch first 5 results
134
-
while users:
135
-
for user in users:
136
-
print(f"User: {user['name']} ({user['email']})")
137
-
users = cursor.fetchmany(5) # Fetch next 5
144
+
cursor = connection.cursor(DictCursor)
145
+
cursor.execute('SELECT name, email FROM users')
146
+
row = cursor.fetchone()
147
+
print(row['name']) # Access by column name
138
148
```
139
149
140
150
## Supported SQL Features
@@ -166,19 +176,6 @@ while users:
166
176
- LIMIT: `LIMIT 10`
167
177
- Combined: `ORDER BY created_at DESC LIMIT 5`
168
178
169
-
## Limitations & Roadmap
170
-
171
-
**Note**: Currently PyMongoSQL focuses on Data Query Language (DQL) operations. The following SQL features are **not yet supported** but are planned for future releases:
These features are on our development roadmap and contributions are welcome!
181
-
182
179
## Apache Superset Integration
183
180
184
181
PyMongoSQL can be used as a database driver in Apache Superset for querying and visualizing MongoDB data:
@@ -200,6 +197,21 @@ PyMongoSQL can be used as a database driver in Apache Superset for querying and
200
197
201
198
This allows seamless integration between MongoDB data and Superset's BI capabilities without requiring data migration to traditional SQL databases.
202
199
200
+
<h2style="color: red;">Limitations & Roadmap</h2>
201
+
202
+
**Note**: Currently PyMongoSQL focuses on Data Query Language (DQL) operations. The following SQL features are **not yet supported** but are planned for future releases:
These features are on our development roadmap and contributions are welcome!
214
+
203
215
## Contributing
204
216
205
217
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
0 commit comments