DBManager is a simple yet powerful C++ program designed to interact with SQLite databases. It allows users to create, manage, and query databases through both automated and interactive modes. The project is modular, with clear separation of functionality for logging, database interaction, and user interaction.
- Create and interact with SQLite databases.
- Execute SQL queries such as
CREATE,INSERT,UPDATE,DELETE, andSELECT. - Interactive mode for manual SQL query execution.
- Logs all database actions to a log file for auditing.
- Modular design for extensibility.
To build and run this project, ensure you have the following installed:
- C++ Compiler (e.g.,
g++) - SQLite3 Library
Install SQLite3 library if not already installed:sudo apt-get install libsqlite3-dev # For Debian/Ubuntu brew install sqlite # For macOS
-
Clone this repository:
git clone https://github.com/your-username/DBManager.git cd DBManager -
Compile the project:
g++ main.cpp database.cpp logger.cpp interactive_mode.cpp -o dbmanager -lsqlite3
-
Run the program:
./dbmanager
-
Automated Execution
The program will:- Create a database file named
example.db(if not already present). - Create a table called
users. - Insert some sample data (
AliceandBob). - Fetch and display the data from the
userstable.
- Create a database file named
-
Interactive Mode
Enter interactive mode to manually execute SQL queries:./dbmanager
Type SQL commands directly into the terminal. For example:
SELECT * FROM users; INSERT INTO users (name) VALUES ('Charlie');
Type
exitto quit interactive mode. -
Logs
All executed queries and actions are logged to a file nameddatabase.log.
DBManager/
├── main.cpp # Program entry point
├── database.h # Database class header
├── database.cpp # Database class implementation
├── logger.h # Logger class header
├── logger.cpp # Logger class implementation
├── interactive_mode.h # Interactive mode header
├── interactive_mode.cpp # Interactive mode implementation
└── README.md # Project documentation
Contributions are welcome! If you’d like to improve this project:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name. - Commit your changes:
git commit -m 'Add some feature'. - Push to the branch:
git push origin feature-name. - Open a pull request.
If you have any questions or suggestions, feel free to open an issue or reach out at discord yalokgar.