pgweb/README.md

196 lines
4.3 KiB
Markdown
Raw Normal View History

2014-10-08 21:29:43 -05:00
# pgweb
2014-10-10 21:06:08 -05:00
Web-based PostgreSQL database browser written in Go.
2014-10-08 21:29:43 -05:00
2014-12-09 19:49:29 -06:00
[![Release](https://img.shields.io/github/release/sosedoff/pgweb.svg)](https://github.com/sosedoff/pgweb/releases)
[![Build Status](https://img.shields.io/travis/sosedoff/pgweb.svg)](https://travis-ci.org/sosedoff/pgweb)
2014-10-27 22:12:56 -05:00
2014-10-13 21:02:04 -05:00
## Overview
This is a web-based browser for PostgreSQL database server. Its written in Go
and works on Mac OSX, Linux and Windows machines. Main idea behind using Go for the backend
is to utilize language's ability for cross-compile source code for multiple platforms.
This project is an attempt to create a very simple and portable application to work with
PostgreSQL databases.
2014-10-14 11:34:22 -05:00
<img src="screenshots/browse.png" width="345px" />
<img src="screenshots/query.png" width="345px" />
2014-10-23 09:11:40 -06:00
Features:
- Connect to local or remote server
- Browse tables and table rows
- Get table details: structure, size, indices, row count
- Execute SQL query and run analyze on it
- Export query results to CSV
- View query history
2014-10-13 21:02:04 -05:00
## Installation
Please visit [Github Releases](https://github.com/sosedoff/pgweb/releases) to download a
precompiled binary for your operating system.
Currently supported:
2014-10-13 21:03:42 -05:00
- Mac OSX 64bit
2014-10-13 21:02:04 -05:00
- Linux 32/64bit
- Windows 32/64bit
2014-10-16 17:42:40 -05:00
Supported PostgreSQL versions:
- 9.1
- 9.2
- 9.3
Older versions of PostgreSQL might also work but this project is not tested on
8.x branches.
2014-10-29 11:58:32 -07:00
## Run on Heroku
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/sosedoff/pgweb)
2014-10-08 21:29:43 -05:00
## Usage
2014-10-13 21:03:42 -05:00
Start server:
2014-11-07 18:12:08 -06:00
```
pgweb
```
You can also provide connection flags:
2014-10-13 21:03:42 -05:00
```
2014-10-14 10:52:40 -05:00
pgweb --host localhost --user myuser --db mydb
2014-10-13 21:03:42 -05:00
```
2014-11-07 18:12:08 -06:00
Connection URL scheme is also supported:
2014-10-13 21:02:04 -05:00
```
2014-11-07 18:12:08 -06:00
pgweb --url postgres://user:password@host:port/database?sslmode=[mode]
2014-10-13 21:02:04 -05:00
```
It works great with [Heroku Postgres](https://postgres.heroku.com) if you need
to troubleshoot production database or simply run a few queries.
2014-12-04 23:35:25 -06:00
### SSH Gateway
If your postgres server is running behind firewall, you can connect to it using
ssh gateways. First, you'll need to run a ssh command:
```
ssh -Ng -L 5433:localhost:5432 user@remotehost.com
```
Then you can start pgweb with the following command:
```
pgweb --url postgres://user:password@localhost:5433/database
```
2014-11-07 18:12:08 -06:00
### CLI options
2014-10-08 21:29:43 -05:00
```
2014-10-13 21:02:04 -05:00
Usage:
pgweb [OPTIONS]
Application Options:
2014-10-29 19:45:12 -05:00
-v, --version Print version
-d, --debug Enable debugging mode (false)
2014-11-07 18:12:08 -06:00
-s, --skip-open Skip browser open on start
2014-10-29 19:45:12 -05:00
--url= Database connection string
--host= Server hostname or IP (localhost)
--port= Server port (5432)
--user= Database user (postgres)
--pass= Password for user
--db= Database name (postgres)
--ssl= SSL option (disable)
--bind= HTTP server host (localhost)
2014-10-29 19:45:12 -05:00
--listen= HTTP server listen port (8080)
--auth-user= HTTP basic auth user
--auth-pass= HTTP basic auth password
2014-10-08 21:29:43 -05:00
```
2014-11-07 18:12:08 -06:00
## Build from source
2014-10-08 21:54:49 -05:00
2014-10-10 21:06:08 -05:00
Go 1.3+ is required. You can install Go with `homebrew`:
2014-10-08 21:54:49 -05:00
```
2014-10-10 21:06:08 -05:00
brew install go
2014-10-09 19:23:19 -05:00
```
2014-10-10 21:06:08 -05:00
To compile source code run the following command:
2014-10-08 21:29:43 -05:00
```
2014-10-24 20:52:53 -05:00
make setup
2014-10-13 18:31:28 -05:00
make dev
2014-10-09 19:23:19 -05:00
```
2014-10-13 21:02:04 -05:00
This will produce `pgweb` binary in the current directory.
2014-10-21 07:25:58 -07:00
There's also a task to compile binaries for other operating systems:
```
make build
```
Under the hood it uses [gox](https://github.com/mitchellh/gox). Compiled binaries
will be stored into `./bin` directory.
2014-11-03 14:35:56 +08:00
2014-11-07 18:12:08 -06:00
## Use in Docker
2014-11-03 14:35:56 +08:00
2014-11-07 18:12:08 -06:00
Build the image:
2014-11-03 14:35:56 +08:00
```
2014-11-07 18:12:08 -06:00
docker build -t pgweb .
2014-11-03 14:35:56 +08:00
```
2014-11-07 18:12:08 -06:00
Start container:
2014-11-03 14:35:56 +08:00
```
2014-11-07 18:12:08 -06:00
docker run [OPTIONS of docker] pgweb [OPTIONS of pgweb]
2014-11-03 14:35:56 +08:00
```
2014-11-07 18:12:08 -06:00
### Example
2014-11-03 14:35:56 +08:00
2014-11-07 18:12:08 -06:00
Run postgresql container:
2014-11-03 14:35:56 +08:00
```
2014-11-07 18:12:08 -06:00
docker run -d \
--name="postgresql" \
-p 5432:5432 \
-e USER="testuser" \
-e DB="testdb" \
-e PASS="test123" \
paintedfox/postgresql
2014-11-03 14:35:56 +08:00
```
2014-11-07 18:12:08 -06:00
Run pgweb container:
2014-11-03 14:35:56 +08:00
```
2014-11-07 18:12:08 -06:00
docker run -d \
-p 8080:8080 pgweb \
--url postgres://testuser:test123@your-ip:5432/testdb \
--bind 0.0.0.0
```
Then open [http://your-ip:8082](#) in your browser.
## Contributing
- Fork repository
- Create a feature or bugfix branch
- Open a new pull request
- Use github issues for any questions
2014-11-03 14:35:56 +08:00
2014-11-07 18:12:08 -06:00
## Contact
2014-10-13 21:02:04 -05:00
2014-11-07 18:12:08 -06:00
- Dan Sosedoff
- [dan.sosedoff@gmail.com](mailto:dan.sosedoff@gmail.com)
- [http://twitter.com/sosedoff](http://twitter.com/sosedoff)
2014-10-13 21:02:04 -05:00
## License
The MIT License (MIT)
2014-11-07 18:12:08 -06:00
Copyright (c) 2014 Dan Sosedoff, <dan.sosedoff@gmail.com>