Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maragudk/dblens
An HTTP handler for database browsing.
https://github.com/maragudk/dblens
go golang http-handler
Last synced: 3 months ago
JSON representation
An HTTP handler for database browsing.
- Host: GitHub
- URL: https://github.com/maragudk/dblens
- Owner: maragudk
- License: mit
- Created: 2022-12-07T09:26:37.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-27T10:23:22.000Z (almost 2 years ago)
- Last Synced: 2023-11-29T09:45:18.247Z (about 1 year ago)
- Topics: go, golang, http-handler
- Language: Go
- Homepage:
- Size: 34.2 KB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dblens
An HTTP handler for database browsing.
BEWARE: `dblens.Handler` accepts ALL queries, including destructive ones. Don't expose the handler to the wide public.
## Usage
```shell
go get -u github.com/maragudk/dblens
``````go
package mainimport (
"database/sql"
"errors"
"log"
"net/http"
"os"_ "github.com/mattn/go-sqlite3"
"github.com/maragudk/dblens"
)func main() {
os.Exit(start())
}func start() int {
log := log.New(os.Stderr, "", log.Ldate|log.Ltime|log.Lshortfile|log.LUTC)db, err := sql.Open("sqlite3", "app.db?_journal=WAL&_timeout=5000&_fk=true")
if err != nil {
log.Println("Error opening database:", err)
return 1
}log.Println("Starting on http://localhost:8080")
if err := http.ListenAndServe("localhost:8080", dblens.Handler(db, "sqlite3")); err != nil &&
!errors.Is(err, http.ErrServerClosed) {
log.Println("Error:", err)
return 1
}return 0
}
```## Screenshot
![screenshot.png](docs%2Fscreenshot.png)
Made in 🇩🇰 by [maragu](https://www.maragu.dk/), maker of [online Go courses](https://www.golang.dk/).