A full-featured database management application for macOS, built with SwiftUI.
Passwords are currently stored in plain text. Connection credentials are saved using SwiftData in an unencrypted SQLite database. See SECURITY.md for details and recommended security practices.
For production use: Use SSH keys, system SSH config, or don't save passwords.
-
Multiple Connection Types:
- TCP/IP connections
- Unix socket connections
- SSH tunnels (TCP)
-
Database Support:
- MySQL (via MySQLNIO)
- PostgreSQL (via PostgresNIO)
- SQLite (via SQLite.swift)
-
SSH Authentication:
- System SSH config (
~/.ssh/config) integration - Password authentication
- Public key authentication
- SSH agent support
- System SSH config (
-
Left Sidebar: Hierarchical database and table browser
- Expandable database list
- Table listing per database
- Double-click to open tables in tabs
- Right-click for table actions
-
Center Panel: Tabbed interface for open tables
- Multiple tables can be open simultaneously
- Close tabs with ⌘W
- Each table has four sub-tabs:
- Content: Editable data grid with filtering, sorting, and pagination
- Information: Table metadata (name, row count, engine, collation, comment)
- Structure: Column definitions (indexes and foreign keys temporarily disabled)
- SQL Console: Execute custom queries on the table
-
Bottom Panel: Activity Log & SQL Console
- Activity Log: Color-coded connection diagnostics (info, success, warning, error)
- SQL Console: Global SQL editor for executing queries
- Execute queries with ⌘↩
- View results in grid format
- Query execution time tracking
- Save and manage multiple database connections
- Connections persist using SwiftData
- Quick connect/disconnect from toolbar
- Comprehensive connection configuration form
- macOS 14.0 or later
- Xcode 15.0 or later
- Swift 5.9 or later
First time setup:
# 1. Open project in Xcode
open SwiftDB.xcodeproj
# 2. Follow instructions in SETUP_DEPENDENCIES.md to add:
# - MySQLNIO package
# - PostgresNIO package
# 3. Build the project
# Press ⌘B in Xcode, or:
xcodebuild -scheme SwiftDB -project SwiftDB.xcodeproj buildSubsequent builds:
# Build for Debug
xcodebuild -scheme SwiftDB -project SwiftDB.xcodeproj -configuration Debug build
# Build for Release
xcodebuild -scheme SwiftDB -project SwiftDB.xcodeproj -configuration Release build
# Run from Xcode
open SwiftDB.xcodeproj
# Then press ⌘R to runSwiftDB/
├── Models/
│ ├── ConnectionSettings.swift # Connection configuration (SwiftData)
│ ├── DatabaseSchema.swift # Database metadata structures
│ ├── TabManager.swift # Tab state management
│ ├── TableEditManager.swift # Table editing state
│ ├── FilterModels.swift # Filtering data structures
│ ├── ActivityLog.swift # Connection activity logging
│ └── Preferences.swift # App preferences
├── Services/
│ ├── DatabaseConnection.swift # Database orchestration
│ ├── MySQLConnector.swift # MySQL driver (MySQLNIO)
│ ├── PostgreSQLConnector.swift # PostgreSQL driver (PostgresNIO)
│ ├── SQLiteConnector.swift # SQLite driver (SQLite.swift)
│ ├── SSHTunnel.swift # SSH tunnel management
│ └── CLIArguments.swift # Command-line argument parsing
└── Views/
├── MainView.swift # Root layout with sidebar
├── SidebarView.swift # Database/table browser
├── TabContentView.swift # Tab management
├── TableInformationView.swift # Table metadata display
├── TableStructureView.swift # Column/index/FK viewer
├── TableDataView.swift # Data grid with editing
├── ConsoleView.swift # SQL console
├── ConnectionSheetView.swift # Connection form
├── ConnectionManagerView.swift # Saved connections list
├── ActivityLogView.swift # Connection activity viewer
├── FilterBarView.swift # Column filtering UI
└── SettingsView.swift # App settings
- SwiftUI: Declarative UI framework
- SwiftData: Persistent storage for connections
- @Observable: Reactive state management
- Async/Await: Non-blocking database operations
- SSH: System SSH integration for secure tunneling
-
Click the "+" button in the toolbar or the "New Connection" button on the welcome screen
-
Fill in the connection details:
- Connection Name: A friendly name for this connection
- Connection Type: Choose TCP/IP, Socket, or SSH Tunnel
- Database Type: MySQL, PostgreSQL, or SQLite
- Host/Port or Socket: Database server location
- Username/Password: Database credentials
- SSH Settings (if using SSH tunnel):
- SSH host and port
- SSH username
- Authentication method (config, password, key, agent)
- Optional: SSH key path and passphrase
-
Click "Connect"
If you have an existing ~/.ssh/config file, SwiftDB can use it:
# Example ~/.ssh/config
Host myserver
HostName example.com
User myuser
Port 22
IdentityFile ~/.ssh/id_rsa
Simply select "System SSH Config" as the authentication method and enter "myserver" as the SSH host.
- Expand a database in the sidebar by clicking on it
- Double-click a table to open it in a new tab
- Use the segmented control to switch between Information, Structure, and Content views
- Click in the console at the bottom of the window
- Type your SQL query
- Press ⌘↩ to execute
- View results in the console area
IMPORTANT: Before running the app, you must add the required Swift Package dependencies:
- See SETUP_DEPENDENCIES.md for detailed instructions
- Add MySQLNIO and PostgresNIO packages in Xcode
- Build the project (⌘B)
The app now uses real database connectivity - it will connect to actual MySQL and PostgreSQL servers and execute real queries.
- In-place cell editing (double-click cells)
- Large content editor for long text fields
- Pending changes tracking with orange highlighting
- Commit/rollback functionality
- UPDATE statement generation with proper WHERE clauses
- Column-based filtering with multiple operators (equals, contains, starts with, etc.)
- Column sorting (ascending/descending)
- Pagination with customizable page sizes (10-500 rows)
- Resizable columns with persistent width storage
- Zebra striping for improved readability
- Dynamic SSH tunnel port allocation (no hardcoded ports)
- Comprehensive activity logging with color-coded messages
- CLI arguments support for automated testing
- File browser for SQLite databases and SSH keys
- Query result export (CSV, JSON, etc.)
- Database schema diffing
- Query history persistence
- Multiple simultaneous connections
- Foreign keys and indexes display (temporarily disabled due to MySQLNIO limitations)
This is a template/framework for a database management application. Feel free to:
- Add real database driver implementations
- Enhance the UI with additional features
- Add support for more database types
- Implement data editing capabilities
- Add import/export functionality
This project is provided as-is for educational and development purposes.