MyDB is a powerful database management tool that provides Git-like branching functionality for MySQL databases. It allows developers to create isolated database environments, manage migrations, and merge changes between branches.
📚 Related Documentation:
- 🌳 Git-like branching for databases
- 📊 Table creation and management
- 🔄 Database migrations with up/down support
- 🔀 Branch merging capabilities
- 📱 GUI interface via MyDB Studio
- 🔒 Automated schema tracking
- 📝 Detailed migration history
- Python 3.7+
- MySQL Server 5.7+ or 8.0+
- pip (Python package manager)
- Clone the repository:
git clone https://github.com/yourusername/mydb-cli.git
cd mydb-cli
- Create and activate a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the package in development mode:
pip install -e .
- Install required dependencies:
pip install -r requirements.txt
- Make the CLI tool accessible system-wide:
# Add to your .bashrc or .zshrc:
export PATH="$PATH:/path/to/mydb-cli/bin"
# On Windows, add the bin directory to your system PATH
- Initialize your database configuration:
mydb-cli status
This will create a default configuration file at .mydb/config.json
.
- Update the configuration file with your MySQL credentials:
{
"connection": {
"user": "your_username",
"password": "your_password",
"host": "localhost",
"port": 3306,
"database": "your_database",
"auth_plugin": "mysql_native_password"
}
}
Create a new branch:
mydb-cli create-branch --branch dev
List all branches:
mydb-cli list-branches
Switch to a different branch:
mydb-cli switch-branch --branch dev
Delete a branch:
mydb-cli delete-branch --branch old_feature
Merge branches:
mydb-cli merge-branch --source feature --target main
Create a new table:
mydb-cli create-table --name users
# Follow the interactive prompts to define columns
List all tables:
mydb-cli list-tables
Describe table structure:
mydb-cli describe-table --name users
Drop a table:
mydb-cli drop-table --name old_table
Create a new migration:
mydb-cli create-migration --name add_users_table --description "Create users table with basic fields"
Apply migrations:
mydb-cli migrate-up # Apply next pending migration
mydb-cli apply-migration --number 1 # Apply specific migration
Rollback migrations:
mydb-cli migrate-down # Rollback last applied migration
Check migration status:
mydb-cli migration-status
Launch the MyDB Studio interface:
mydb-cli studio
.
├── LICENSE
├── README.md
├── assets
│ ├── index-BKO7flFT.css
│ └── index-D0-aluUL.js
├── image-1.png
├── image.png
├── index.html
├── main.py
├── migrations/
├── requirements.txt
├── streamlit.png
├── studio.py
├── testsqlcode01.txt
├── testsqlcode02.txt
└── vite.svg
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details. This would allow me to make some features of this tool to be served on a proprietory basis as well where i'll earn by providing subscriptions for my dev tool features.
If you encounter any issues or have questions, please open an issue on GitHub.