|
| 1 | +# SQLite Admin |
| 2 | + |
| 3 | +SQLite Admin provides a lightweight web server to interact with a SQLite database. It allows you to: |
| 4 | + |
| 5 | +- Browse tables and their schemas. |
| 6 | +- View table data along with adding filters, limits and offsets. |
| 7 | +- Modify individual columns in existing rows. |
| 8 | + |
| 9 | +It can either by installed as a binary or embedded into an existing Golang backend as a library. |
| 10 | + |
| 11 | +The web server can be interacted with by going to https://sqliteadmin.dev. |
| 12 | + |
| 13 | +The source code for the web UI can be found at https://github.com/joelseq/sqliteadmin-ui |
| 14 | + |
| 15 | + |
| 16 | +## Motivation |
| 17 | + |
| 18 | +SQLite is very easy to add as an embedded database but it's difficult to manage the database once it's deployed in an application. |
| 19 | + |
| 20 | +Existing tools primarily focus on local SQLite files, requiring manual interaction through CLI tools or desktop applications. If your SQLite database is running embedded within an application, there are few (if any) solutions that let you inspect, query, and modify it without complex workarounds. |
| 21 | + |
| 22 | +The alternative is to use a cloud-hosted version like those provided by [Turso](https://turso.tech/) which enables interacting with the database using tools like [Drizzle Studio](https://orm.drizzle.team/drizzle-studio/overview). This adds complexity to the setup and deployment of your application and you lose out on the value of having an embedded database. |
| 23 | + |
| 24 | +This project fills that gap by providing an easy way to view and manage an embedded SQLite database via a web UI—no need to migrate to a cloud provider or use ad-hoc solutions. |
| 25 | + |
| 26 | +## Installing as a binary |
| 27 | + |
| 28 | +1. Using `go install`: |
| 29 | + |
| 30 | +```bash |
| 31 | +go install github.com/joelseq/sqliteadmin-go/cmd/sqliteadmin@latest |
| 32 | +``` |
| 33 | + |
| 34 | +2. Using `go build` (after cloning the repository): |
| 35 | + |
| 36 | +```bash |
| 37 | +make build |
| 38 | +``` |
| 39 | +This will add the `sqliteadmin` binary to `/tmp/bin` |
| 40 | + |
| 41 | +### Usage |
| 42 | + |
| 43 | +In order to add authentication, the following environment variables are required: `SQLITEADMIN_USERNAME`, `SQLITEADMIN_PASSWORD`. |
| 44 | + |
| 45 | +e.g.: |
| 46 | +```bash |
| 47 | +export SQLITEADMIN_USERNAME=user |
| 48 | +export SQLITEADMIN_PASSWORD=password |
| 49 | +``` |
| 50 | + |
| 51 | +Start the server |
| 52 | + |
| 53 | +```bash |
| 54 | +sqliteadmin serve <path to sqlite db> -p 8080 |
| 55 | +``` |
| 56 | + |
| 57 | +Your SQLite database can now be accessed by visiting https://sqliteadmin.dev and providing the credentials and endpoint (including port). |
| 58 | + |
| 59 | +## Using as a library |
| 60 | + |
| 61 | +Check out the `examples/` directory to see how to integrate it into an existing Golang backend. |
| 62 | + |
| 63 | +You can also run the examples to test out the admin UI: |
| 64 | + |
| 65 | +```bash |
| 66 | +go run examples/chi/main.go |
| 67 | +``` |
| 68 | + |
| 69 | +This will spin up a server on `http://localhost:8080`. You can then interact with your local server by going to `https://sqliteadmin.dev` and passing in the following credentials: |
| 70 | + |
| 71 | +``` |
| 72 | +username: user |
| 73 | +password: password |
| 74 | +endpoint: http://localhost:8080/admin |
| 75 | +``` |
| 76 | + |
| 77 | +> [!NOTE] |
| 78 | +> If you are seeing "An unexpected error occurred" when trying to connect, try disabling your adblock. |
| 79 | +
|
| 80 | +## Inspiration |
| 81 | + |
| 82 | +The UI is heavily inspired by [Drizzle Studio](https://orm.drizzle.team/drizzle-studio/overview). |
0 commit comments