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
* enhance Connection
* Add trigger for feature branch
* Fix code smell
* Update readme
* Fix test cases
* Refactor test cases
* Fixed test case
* Add more cases for query
* Fix code formatting issue
* Fixed something bugs
* Add sqlalchemy support
* Update readme
* Update README
* Update README
* Fixed bugs
* Fix test cases which can run on remote server
* Enhance CI Test to run tests against sqlalchemy 1.x and 2.x
* Clean up the folders
* Splitted requirements.txt
* Register dialect
* Add supports for Superset
---------
Co-authored-by: Peng Ren <[email protected]>
PyMongoSQL is a Python [DB API 2.0 (PEP 249)](https://www.python.org/dev/peps/pep-0249/) client for [MongoDB](https://www.mongodb.com/). It provides a familiar SQL interface to MongoDB, allowing developers to use SQL queries to interact with MongoDB collections.
12
+
PyMongoSQL is a Python [DB API 2.0 (PEP 249)](https://www.python.org/dev/peps/pep-0249/) client for [MongoDB](https://www.mongodb.com/). It provides a familiar SQL interface to MongoDB, allowing developers to use SQL to interact with MongoDB collections.
10
13
11
14
## Objectives
12
15
13
16
PyMongoSQL implements the DB API 2.0 interfaces to provide SQL-like access to MongoDB. The project aims to:
14
17
15
-
- Bridge the gap between SQL and NoSQL by providing SQL query capabilities for MongoDB
18
+
- Bridge the gap between SQL and NoSQL by providing SQL capabilities for MongoDB
16
19
- Support standard SQL DQL (Data Query Language) operations including SELECT statements with WHERE, ORDER BY, and LIMIT clauses
17
20
- Provide seamless integration with existing Python applications that expect DB API 2.0 compliance
18
21
- Enable easy migration from traditional SQL databases to MongoDB
19
-
- Support field aliasing and projection mapping for flexible result set handling
20
-
- Maintain high performance through direct `db.command()` execution instead of high-level APIs
21
22
22
23
## Features
23
24
24
25
-**DB API 2.0 Compliant**: Full compatibility with Python Database API 2.0 specification
26
+
-**SQLAlchemy Integration**: Complete ORM and Core support with dedicated MongoDB dialect
25
27
-**SQL Query Support**: SELECT statements with WHERE conditions, field selection, and aliases
26
-
-**MongoDB Native Integration**: Direct `db.command()` execution for optimal performance
27
28
-**Connection String Support**: MongoDB URI format for easy configuration
28
-
-**Result Set Handling**: Support for `fetchone()`, `fetchmany()`, and `fetchall()` operations
29
-
-**Field Aliasing**: SQL-style field aliases with automatic projection mapping
30
-
-**Context Manager Support**: Automatic resource management with `with` statements
31
-
-**Transaction Ready**: Architecture designed for future DML operation support (INSERT, UPDATE, DELETE)
32
29
33
30
## Requirements
34
31
35
32
-**Python**: 3.9, 3.10, 3.11, 3.12, 3.13+
36
-
-**MongoDB**: 4.0+
33
+
-**MongoDB**: 7.0+
37
34
38
35
## Dependencies
39
36
@@ -43,6 +40,11 @@ PyMongoSQL implements the DB API 2.0 interfaces to provide SQL-like access to Mo
43
40
-**ANTLR4** (SQL Parser Runtime)
44
41
- antlr4-python3-runtime >= 4.13.0
45
42
43
+
### Optional Dependencies
44
+
45
+
-**SQLAlchemy** (for ORM/Core support)
46
+
- sqlalchemy >= 1.4.0 (SQLAlchemy 1.4+ and 2.0+ supported)
47
+
46
48
## Installation
47
49
48
50
```bash
@@ -67,7 +69,7 @@ from pymongosql import connect
67
69
# Connect to MongoDB
68
70
connection = connect(
69
71
host="mongodb://localhost:27017",
70
-
database="test_db"
72
+
database="database"
71
73
)
72
74
73
75
cursor = connection.cursor()
@@ -97,44 +99,19 @@ for row in cursor:
97
99
```python
98
100
from pymongosql import connect
99
101
100
-
with connect(host="mongodb://localhost:27017", database="mydb") as conn:
102
+
with connect(host="mongodb://localhost:27017/database") as conn:
101
103
with conn.cursor() as cursor:
102
104
cursor.execute('SELECT COUNT(*) as total FROM users')
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