A comprehensive web-based SQLite database viewer and manager built with Go and Gin framework. Features a clean, modern interface for browsing tables, executing queries, and managing database schemas.
- File Upload: Drag & drop or browse to upload SQLite database files
- Manual Path Entry: Enter database file paths directly
- Auto-Upload Handling: Uploaded files are automatically saved with unique timestamps
- localStorage Persistence: Selected database is saved in browser for session continuity
- Database Availability Check: Automatic verification and redirect if database becomes unavailable
- Table Browsing: View all database tables in a clean grid layout
- Schema Display: Complete table schema with column types, constraints, and defaults
- Data Pagination: Paginated table data viewing (20 rows per page)
- Primary Key Detection: Automatic identification and use of primary keys
- Dynamic Column Management: Add/remove columns during table creation
- Data Type Support: All SQLite types (INTEGER, TEXT, REAL, BLOB, NUMERIC)
- Constraint Configuration: Primary keys, NOT NULL constraints, default values
- Validation: Smart warnings for missing primary keys
- Seamless Redirect: Automatic navigation to newly created tables
- Create: Insert new rows with form-based input
- Read: View table data with proper column alignment
- Update: Inline editing of existing rows with save/cancel options
- Delete: Row deletion with confirmation dialogs
- Smart Primary Key Handling: Automatic detection and use of table primary keys
- Inline Schema Editing: Edit table schema without leaving the page
- Add Columns: Add new columns with type and constraints
- Edit Columns: Modify column definitions (limited in SQLite)
- Drop Columns: Remove columns from tables
- AJAX Operations: All schema changes happen without page refreshes
- Custom Queries: Execute any SQL query with results display
- Query Examples: Pre-populated example queries for common operations
- Keyboard Shortcuts: Ctrl+Enter to submit queries quickly
- Result Display: Tabular display of query results with row counts
- Responsive Design: Works on desktop and mobile devices
- Modern CSS: Clean, professional styling with CSS Grid
- Navigation: Consistent navigation across all pages
- Error Handling: Clear error messages and success notifications
- Loading States: Proper feedback during operations
sqlite-viewer/
βββ main.go # Application entry point
βββ models.go # Data structures and types
βββ db.go # Database management operations
βββ handlers.go # HTTP request handlers
βββ routes.go # Route configuration
βββ templates/ # HTML templates
β βββ home.html # Database selection page
β βββ tables.html # Tables listing with creation
β βββ table.html # Table data and schema view
β βββ query.html # SQL query interface
βββ static/ # Static assets
β βββ style.css # Application styles
βββ uploads/ # Uploaded database files
- Backend: Go with Gin web framework
- Database: modernc.org/sqlite (pure Go SQLite driver)
- Frontend: HTML5, CSS3, JavaScript (ES6+)
- Templates: Go template engine with custom functions
- File Handling: Multipart form uploads with unique naming
- Go 1.19 or later
- SQLite database files
- Clone or download the project
- Navigate to the project directory
- Install dependencies:
go mod tidy
- Run the application:
go run main.go
The application will start on http://localhost:8080
- File Upload: Click "Browse" to select a SQLite file, or drag & drop onto the drop zone
- Manual Path: Click "Enter Path Manually" to type a database file path
- Session Persistence: Selected database is automatically saved for the session
- Select a database to view all tables in a grid layout
- Click "View Data" on any table card to see its contents
- Navigate paginated data using the pagination controls
- Navigate to the Tables page
- Click "Create New Table" button
- Enter table name
- Add columns with types and constraints:
- Column Name: Descriptive name for the column
- Type: Data type (INTEGER, TEXT, REAL, BLOB, NUMERIC)
- PK: Check for primary key
- NOT NULL: Check for required fields
- Default: Default value for the column
- Click "Create Table" to create and navigate to the new table
- Insert: Click "Insert New Row" button, fill in the form, and submit
- Edit: Click "Edit" on any row, modify values in-place, and click "Save"
- Delete: Click "Delete" on any row and confirm the action
- Navigate to a table page
- Click "Edit Schema" button
- Edit Column: Click "Edit" on any column row, modify values, and click "Save"
- Add Column: Click "Add New Column", enter details, and click "Save"
- Delete Column: Click "Delete" on any non-primary key column and confirm
- Click "Done Editing" to exit schema edit mode
- Navigate to the Query page
- Enter SQL queries in the textarea
- Use Ctrl+Enter to execute quickly
- View results in tabular format below
GET /- Home page (database selection)POST /opendb- Open database (file upload or path)GET /checkdb- Check database availability
GET /tables- List all tablesGET /table/:name- View table data and schemaGET /query- SQL query pagePOST /query- Execute SQL query
POST /table/:name/insert- Insert new rowPOST /table/:name/update/:id- Update existing rowPOST /table/:name/delete/:id- Delete row
POST /table/:name/schema/add- Add columnPOST /table/:name/schema/update/:column- Update columnPOST /table/:name/schema/drop/:column- Drop column
- Port: 8080
- Page Size: 20 rows
- Upload Directory:
uploads/ - Static Files:
static/ - Templates:
templates/
GIN_MODE: Set toreleasefor production deployment
- File Upload: Uploaded files are saved with timestamp-based unique names
- SQL Injection: All queries use parameterized statements
- Path Traversal: Database file paths are validated for existence
- CORS: Not configured for cross-origin requests (security by default)
- Column Modification: SQLite doesn't support ALTER COLUMN directly - requires table recreation
- DROP COLUMN: Limited support in older SQLite versions
- Foreign Keys: No foreign key constraint management in current version
- Concurrent Users: Single-user application (no user authentication)
- Database Size: Limited by available memory for large result sets
- File Types: Only SQLite database files (.db, .sqlite, .sqlite3) are supported
- main.go: Application entry point with minimal setup
- models.go: Data structures (ColumnInfo, TableData, QueryResult, DatabaseManager)
- db.go: All database operations and SQLite interactions
- handlers.go: HTTP request handlers for all endpoints
- routes.go: Route configuration and template setup
- templates/: Standalone HTML templates (no inheritance)
- static/style.css: Complete styling for all pages
- Add new data structures to
models.go - Implement database operations in
db.go - Create HTTP handlers in
handlers.go - Add routes in
routes.go - Update templates as needed
go test ./...- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source. Feel free to use, modify, and distribute as needed.
For issues, questions, or feature requests, please check the project documentation or create an issue in the repository.
Version: 1.0.0 Last Updated: 2025-10-11 Compatibility: Go 1.19+, Modern Browsers