DFox is a Rust-based database management tool that provides a terminal user interface (TUI) for interacting with PostgreSQL and MySQL databases. It allows users to perform database operations easily and efficiently through a simple and intuitive interface.
- Connect to multiple database types: PostgreSQL, MySQL, (SQLite still in development).
- User-friendly terminal interface for managing database connections and performing CRUD operations.
- Dynamic rendering of database schemas and table data.
- Easily extendable for additional database types and features.
- Built-in debug logging system for troubleshooting.
The project is organized as a Cargo workspace consisting of two main components:
- dfox-core: The core library responsible for database operations. It includes implementations for MySQL, PostgreSQL, and SQLite clients, as well as data models and error handling.
- dfox-tui: The command-line interface for user interaction. It contains the main functions for launching the application, along with UI components and event handlers.
DFox includes a comprehensive logging system to help with troubleshooting and development. By default, logging is disabled for better performance. To enable debug logging:
- Create a
.env
file in the project root directory:
# .env file
RUST_LOG=debug
-
Run the application as usual. Debug logs will be written to
dfox-debug.log
in the current directory. -
You can also view debug information directly in the application by pressing F12 while using the interface.
off
- No logging (default)error
- Only errorswarn
- Warnings and errorsinfo
- General information, warnings, and errorsdebug
- Detailed debugging information (recommended for troubleshooting)trace
- Very verbose logging
Example .env
configurations:
# For normal usage (default)
RUST_LOG=off
# For basic error tracking
RUST_LOG=error
# For troubleshooting
RUST_LOG=debug
# For development
RUST_LOG=trace
-
Database Type Selection
Upon starting the application, the user is presented with a menu to select the database type (PostgreSQL, MySQL, or SQLite). Use the up/down keys to navigate and Enter to confirm your choice.
-
Connection Input Screen
After selecting the database type, the user is prompted to input the connection details such as hostname, port, username, and password.
-
Database Selection
Once connected, a list of available databases is displayed. The user can choose the database to interact with.
-
Table View
The application dynamically renders the list of tables available in the selected database.
-
Describe Table
The user can select a table to view its schema, displayed in a tree-like structure, including column names, types, and constraints.
-
Query Execution and Results
The user can execute SQL queries and view the results in the TUI.
-
Error Handling
If there is an error with the query or database operation, an error message is displayed in the interface.
DFox provides several keyboard shortcuts for efficient navigation and operation:
- Tab - Navigate between interface elements
- ↑/↓ - Navigate up/down in lists and tables
- ←/→ - Horizontal scroll in query results
- Page Up/Page Down - Scroll pages in results
- Home/End - Jump to beginning/end of results
- F5 or Ctrl+E - Execute SQL query
- Ctrl+C - Copy selected row to clipboard
- Ctrl+A - Copy all query results to clipboard
- F1 - Return to database selection
- F12 - Toggle debug information display
- Esc or q - Quit application
- Standard text editing controls
- Enter - New line
- Backspace/Delete - Character deletion
To build and run the project, ensure you have Rust installed. Clone the repository and use Cargo to build the project:
git clone https://github.com/markraiter/dfox.git
cd dfox
cargo build
After building the project, you can run the TUI application with the following command:
cargo run --bin dfox-tui
Contributions are welcome! If you would like to contribute to DFox, please follow these steps:
- Fork the repository.
- Create your feature branch (git checkout -b feature/my-feature).
- Commit your changes (git commit -m 'Add some feature').
- Push to the branch (git push origin feature/my-feature).
- Open a pull request.
Thanks to the Ukrainian Rust Community for their incredible support and resources.