Giter Club home page Giter Club logo

sqembv's Introduction

sqembv

sqembv is a Golang embedded web-based SQLite database "browser". It is a fork of sqlite-gobroem which is a little bit modernized and improved.

Main reason for the fork was extremely slow compilation speed of the original project. Also, this fork switched to CGO-optional SQLite driver and fixes some bugs.

Warning: avoid exposing this tool to the public Internet. It does not provide any authentication or authorization and can be used to read and modify your database.

Note: While the original project (and this fork) claims to be a "browser", it allows to execute arbitrary SQL queries.

Embedded Use

Include sqembv in your application:

import "github.com/andrianbdn/sqembv"

Initialize the API controller:

api, err := sqembv.NewAPI("test.sqlite3")
if err != nil {
    log.Fatalln("can not open db:", err)
}

Register the API handler:

http.Handle("/browser/", api.Handler("/browser/"))

or, even better โ€” register it with HTTP basic auth (minimal implementation below)

h := api.Handler("/browser/")

u, p := "sql-user", "PasSw0rd" // Username and Password - CHANGE the password!
golden := "Basic " + base64.StdEncoding.EncodeToString([]byte(u+":"+p))

http.HandleFunc("/browser/", func(w http.ResponseWriter, r *http.Request) {
  if a := r.Header.Get("Authorization"); subtle.ConstantTimeCompare([]byte(a), []byte(golden)) != 1 {
    w.Header().Set("WWW-Authenticate", `Basic realm="restricted", charset="UTF-8"`)
    http.Error(w, "Unauthorized", http.StatusUnauthorized)
    return
  }
  h.ServeHTTP(w, r)
})

Standalone

Use go install to install the latest version of the program:

$ go install github.com/andrianbdn/sqembv/cmd/sqembv@latest

Run sqembv:

$ ./sqembv -h

sqembv, v0.1.1
Usage of ./sqembv:
  -bind string
        HTTP server host (default "localhost")
  -db string
        SQLite database file (default "test.sqlite3")
  -license
        Print program license and exit
  -listen uint
        HTTP server listen port (default 8000)


$ ./sqembv

Open browser http://localhost:8000/

sqembv's People

Contributors

bakaoh avatar andrianbdn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.