A modern database management web tool implemented with Go and Go Template, supporting multiple database types.
- ✅ Establish database connections (supports DSN or form input)
- ✅ List all tables in the database
- ✅ Display table structure (supports one-click copy)
- ✅ Query table data (with pagination)
- ✅ Edit row data in tables
- ✅ Delete row data in tables
- ✅ Execute SQL queries and display results
- ✅ Modular design, easy to extend support for other databases
- ✅ Modern UI with yellow theme (similar to Beekeeper Studio)
- ✅ Support for multi-instance deployment (via custom session storage)
- ✅ Adapter pattern, supports integration with Gin, Echo, and other web frameworks
- ✅ Embedded resources, supports importing via go mod
- MySQL
- PostgreSQL
- SQLite
- ClickHouse
- Dameng (达梦)
- OpenGauss
- Vastbase
- Kingbase (人大金仓)
- OceanDB
go build -o dbweb./dbwebThe server will start at http://localhost:8080.
package main
import (
"github.com/chenhg5/simple-db-web/handlers"
"log"
)
func main() {
server, err := handlers.NewServer()
if err != nil {
log.Fatalf("Failed to create server: %v", err)
}
// Use standard library
server.SetupRoutes()
server.Start(":8080")
// Or use Gin framework
// router := handlers.NewGinRouter(nil)
// server.RegisterRoutes(router)
// router.Engine().Run(":8080")
}-
Connect to Database
- Select database type
- Choose connection method:
- DSN connection string: Enter full DSN directly, e.g.,
user:password@tcp(host:port)/database - Form input: Enter host, port, username, password separately
- DSN connection string: Enter full DSN directly, e.g.,
- Click "Connect" button
-
Select Database
- After successful connection, select the database to operate on
-
View Table List
- After selecting a database, all tables will be displayed on the left
- Click a table name to view its data and structure
-
View Table Data
- View table data in the "Data" tab
- Supports pagination
- Can edit or delete row data
- Action column is fixed on the right for easy operation
-
View Table Structure
- View CREATE TABLE statement in the "Structure" tab
- Supports one-click copy of table structure
-
Execute SQL Queries
- Enter SQL statements in the "SQL Query" tab
- Supports SELECT, UPDATE, DELETE, INSERT operations
- Click "Execute Query" button to run
dbweb/
├── main.go # Main program entry
├── database/ # Database interface and implementations
│ ├── interface.go # Database interface definition
│ ├── mysql.go # MySQL implementation
│ ├── postgresql.go # PostgreSQL implementation
│ ├── sqlite3.go # SQLite implementation
│ ├── clickhouse.go # ClickHouse implementation
│ └── mysql_based*.go # MySQL-compatible database implementations
├── handlers/ # HTTP handlers
│ ├── handlers.go # Routes and handlers
│ ├── adapter*.go # Adapter implementations (Gin, Echo, etc.)
│ ├── embed.go # Resource file embedding
│ ├── templates/ # HTML templates
│ │ └── index.html
│ └── static/ # Static resources
│ ├── style.css
│ └── app.js
├── examples/ # Usage examples
│ ├── gin_example.go # Gin framework example
│ ├── echo_example.go # Echo framework example
│ └── ...
├── docs/ # Documentation
│ ├── zh/ # Chinese documentation
│ └── en/ # English documentation
└── README.md # Documentation
To add support for other databases:
- Create a new implementation file in the
database/directory - Implement the
Databaseinterface - Add the new database type in
handlers/handlers.go'sNewServerfunction
Or use the AddDatabase method to register dynamically:
server.AddDatabase("custom_db", func() database.Database {
return &MyCustomDatabase{}
})Supports Gin, Echo, and other frameworks. See Adapter Usage Guide for details.
Supports persistent storage like Redis, MySQL for multi-instance deployment. See Session Storage Usage Guide for details.
Supports injecting custom JavaScript, such as adding authentication tokens. See Custom JS Usage Guide for details.
- Backend: Go 1.16+
- Database Drivers:
- MySQL:
github.com/go-sql-driver/mysql - PostgreSQL:
github.com/lib/pq - SQLite:
github.com/mattn/go-sqlite3 - ClickHouse:
github.com/ClickHouse/clickhouse-go/v2
- MySQL:
- Frontend: Vanilla JavaScript + CSS
- Templates: Go Template
- Resource Embedding: Go 1.16+ embed
- Adapter Usage Guide - How to integrate with Gin, Echo, and other frameworks
- Session Storage Usage Guide - How to implement multi-instance deployment
- Custom JS Usage Guide - How to add custom JavaScript logic
- Embed Usage Guide - Resource file embedding guide
- Edit and delete operations are based on primary keys (PRI)
- String values in SQL queries are escaped, but parameterized queries are recommended in production
- For multi-instance deployment, Redis or MySQL is recommended as session storage
MIT