ChatDB is an interactive database management tool that supports both SQL databases and MongoDB databases. It provides a user-friendly command-line interface for exploring, querying, and uploading data.
- View database structure and sample table data.
- Auto-generate SQL queries.
- Parse natural language to generate SQL queries.
- Upload table data from CSV files.
- List collections and their field information.
- Auto-generate MongoDB queries.
- Parse natural language to generate MongoDB queries.
- Upload collection data from JSON files.
ChatDB_Project/
│
├── main.py # Main program providing entry point and menu logic
├── mongodb.py # MongoDB-related functionality implementation
├── sql.py # SQL-related functionality implementation
├── requirements.txt # List of required dependencies
└── README.md # Project documentation
git clone https://github.com/your-repo/ChatDB_Project.git
cd ChatDB_Projectpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txt- SQL Database: Update connection details in
sql.py(e.g., host, username, password, database name). - MongoDB Database: Update connection details in
mongodb.py(e.g., host and port).
To start the program, run:
python main.py-
After starting the program, you will see a welcome screen. Choose the type of database:
- Enter
1for SQL database operations. - Enter
2for MongoDB database operations. - Enter
3to exit the program.
- Enter
-
Follow the sub-menu prompts to explore tables/collections, generate queries, or upload data.
This project relies on:
pymysql: For connecting to SQL databases.pymongo: For connecting to MongoDB databases.pandas: For handling CSV data.
Refer to requirements.txt for the complete list.
- Authors: Tengjiang Wang, Zifeng Zhou
- Academic Context: This project is part of USC's DSCI 551 course.
For inquiries, contact Waynewang229@gmail.com.