Giter Club home page Giter Club logo

pgweb's Introduction

pgweb

Simple web-based and cross platform PostgreSQL database explorer.

Release Linux Build Go Report Card GoDoc Docker Pulls

Overview

Pgweb is a web-based database explorer for PostgreSQL, written in Go, and works on Mac, Linux and Windows machines. Distributed as a simple binary with zero dependencies. Very easy to use and packs just the right amount of features.

See application screenshots

Features

  • Cross-platform: Mac/Linux/Windows (64bit).
  • Simple installation (distributed as a single binary).
  • Zero dependencies.
  • Works with PostgreSQL 9.1+.
  • Supports native SSH tunnels.
  • Multiple database sessions.
  • Execute and analyze custom SQL queries.
  • Table and query data export to CSV/JSON/XML.
  • Query history.
  • Server bookmarks.

Visit WIKI for more details.

Demo

Visit https://pgweb-demo.fly.dev/ to see Pgweb in action.

Installation

Usage

Start server:

pgweb

You can also provide connection flags:

pgweb --host localhost --user myuser --db mydb

Connection URL scheme is also supported:

pgweb --url postgres://user:password@host:port/database?sslmode=[mode]
pgweb --url "postgres:///database?host=/absolute/path/to/unix/socket/dir"

Multiple database sessions

To enable multiple database sessions in pgweb, start the server with:

pgweb --sessions

Or set environment variable:

PGWEB_SESSIONS=1 pgweb

Testing

Before running tests, make sure you have PostgreSQL server running on localhost:5432 interface. Also, you must have postgres user that could create new databases in your local environment. Pgweb server should not be running at the same time.

Execute test suite:

make test

If you're using Docker locally, you might also run pgweb test suite against all supported PostgreSQL version with a single command:

make test-all

Contribute

  • Fork this repository
  • Create a new feature branch for a new functionality or bugfix
  • Commit your changes
  • Execute test suite
  • Push your code and open a new pull request
  • Use issues for any questions
  • Check wiki for extra documentation

License

The MIT License (MIT). See LICENSE file for more details.

pgweb's People

Contributors

allisson avatar ashkulz avatar benjamin-thomas avatar burdzwastaken avatar cbandy avatar chenrui333 avatar davetoxa avatar dependabot[bot] avatar ericdagenais avatar frafra avatar jartek avatar jespereneberg avatar joubertredrat avatar ldinc avatar lelvisl avatar llitfkitfk avatar maxine4j avatar nhat002 avatar niiyz avatar oleggator avatar pavel-main avatar simhnna avatar sjonhortensius avatar skabbes avatar sosedoff avatar stevencothren avatar tamird avatar tgmuender avatar trengrj avatar tylerlong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pgweb's Issues

Favicon

Would be really nice to have a clean favicon for pinned tabs and such. I'm no icon designer, but thought I'd mention.

Escape table names

We have a table named "user" (yeah, not great). Viewing the Content shows the current user name instead of the data in the table.

e.g.

select * from user

vs

select * from "user"

Missing hyperlinks on foreign key

This project is missing the most important feature of a database GUI: the ability to view related records...

Basically whenever a foreign key is defined, the value should be linked to the row in the referenced table. Also, ideally, there should be a button to automatically join on foreign keys.

Without this feature, easy navigation is impossible.

Getting "user: Current not implemented on linux/amd64" trying to connect over SSL

Tried to connect using the 'Schema' tab. Specified the ssl=true, sslcert and sslkey in the URI. Running Linux <name> 3.13.0-22-generic #44-Ubuntu SMP Wed Apr 2 20:05:40 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

To reproduce:

  1. Start process using ./pgweb_linux_amd64
  2. Point browser to http://localhost:8080 and select the 'Schema' tab.
  3. Enter url in the format postgresql://user@devenv/appdb?ssl=true&sslcert=/path/to/postgresql.crt&sslkey=/path/to/postgresql.key

The error seems to be (after some quick Googling) to be related to a Go error: http://stackoverflow.com/questions/20609415/cross-compiling-user-current-not-implemented-on-linux-amd64

Please confirm if this is the case - I haven't tried to build from source though.

Installing via brew

What do you think about creating a homebrew formulae to more convinient installing on mac os?

Great project! ๐Ÿ˜ƒ ๐Ÿ‘

Tables with name uppercase

There is a table for example "COM_Abonent", when I click on it
Expected:
to see data
Real result:
"ERROR: pq: relation "com_abonent" does not exist"
Comment:
When I run query:
select * from "COM_Abonent";
I see data from this table

schema support?

I can 'set search_path= schema' and run the query through the browsers, but the tables names show in the left do not change.

thanks.

Cannot sort tables

When clicking on a column header, the table needs to be sorted by that header, and pressing again should invert the sort direction.

Also there should be a GUI to define multi-column sorting.

Prepopulate SQL Query panel

It would be really nice if the SQL Query panel was automatically populated with the query that you had in the default Content pane.

e.g. When you click on the table name in the sidebar, it switches to the Content pane and shows the first X rows of the table. Would be great if when you then clicked on SQL Query it showed:

SELECT a, b, c, ...
FROM table_name
ORDER BY a
LIMIT 25

(or whatever the query actually is)


Looking at the code, I think it's just this: https://github.com/sosedoff/pgweb/blob/master/static/js/app.js#L151

connection specification problems

This looks really cool, but I can't connect.

First attempt:

./pgweb_darwin_amd64 --url=postgresql://myhost:5433/mydb
Connecting to server...
Error: missing "=" after "postgresql://myhost:5433/mydb" in connection info string"

Admittedly, it is documented that URLs start with postgres:, not postgresql:, but it's an easy mistake to make, because libpq supports both. But in any case it shouldn't attempt to interpret a URL it cannot parse as a connection string and then give a bogus error message.

Next try:

./pgweb_darwin_amd64 --url=postgres://myhost:5433/mydb
Connecting to server...
Error: pq: SSL is not enabled on the server

I know the Go lib/pq is very particular about SSL, but the help does indicate that it is off by default:

  --ssl=       SSL option (disable)

But nothing of the sort

./pgweb_darwin_amd64 --url=postgres://myhost:5433/mydb --ssl=disable

works.

OK, so maybe in order to be able to set the SSL option, I cannot use URLs. Next try:

./pgweb_darwin_amd64 --host=myhost --port=5433 --db=mydb --ssl=disable
Connecting to server...
Error: pq: LDAP authentication failed for user "postgres"

So that worked, but why does it default the user to "postgres"? It ought default to my current user name.

Anyway, next try:

./pgweb_darwin_amd64 --host=myhost --port=5433 --db=mydb --ssl=disable --user="Peter Eisentraut"
Connecting to server...
Error: missing "=" after "Eisentraut" in connection info string"

So apparently it needs some quoting when it assembles the connection string?

Authentication

I would like to host this on heroku, so I need to have at least basic http password authentication.

Secure connection with SSL

I would love to leave pgweb running for quick access any-time I need it. However, I don't see a way to secure the connection to the web interface using HTTPS. In my case I have a wildcard cert that will work perfect if I could just tell pgweb to use it somehow.

Is there any current way to secure the connection to pgweb with HTTPS?

Any possibility of this being added in the future?

Unhelpful error message on unsupplied credentials

When invoking the binary without passing any options, the error message is

Connecting to server...
Checking tables...
Error: Database does not have any tables

The implication here is that there is a database that has successfully been reached, but it has no tables. This is almost certainly false - I don't have a role or database by the name of the defaults that psql expects when invoked without arguments.

Switch to go-rice ?

Hi @sosedoff great initiative with this app.

Wondered if you'd switch to go-rice instead of go-bindata ? go-rice allows you to read files from the current dir, or bundle them as a .zip .. and doesn't need a build step to update files.. as it only points to a directory, and serves everything underneath.

https://github.com/GeertJohan/go.rice

I have an app that works that way, I could help out

brew install pgweb

Not an issue but is anyone working on a formula for homebrew? ๐Ÿ˜„

Changelog.md

Hello, what about creating md document with changes on each version?

Kill a running query

Nice application,

I have an enhancement suggestion. You can add an option in order to kill a running query.

Have a nice day

edit

Is there any plan of enabling some sort of row editing?

Connect using SSH tunnel

Everything works fine until you want to connect to a postgres server that sits behind firewall.

The only option in this case is to use ssh tunnels. In order to make it work, user has to use ssh to establish connection with a remote machine. Example:

ssh -Ng -L 5433:localhost:5432 [email protected]

This should work on linux and osx but not on windows, which does not have a standard ssh
binary available. I've been digging around to find any good and stable example on how to run
ssh tunnel programmatically with Go. No luck yet.

Having ability to connect to a behind-firewall postgres instance is very useful and i tend to just go ahead
and implement "experimental" support for this feature using good old exec.Command that'll spawn ssh
and establish a tunnel. I have already tried this solution and it works great (except when internet connection is shitty), client code that communicates with postgres server does not have to be changed at all. But it makes pgweb environment-dependent, which is not great.

Would like to get some feedback or even examples on how to get this feature done.

@cbandy @pvh any thoughts?

Content tab doesn't double-quote table in query

In postgres, identifiers need to be named with double-quotes if they're not all lowercase. For example, I have a table Accounts, and when I click the "content" tab, I see:

ERROR: pq: relation "account" does not exist

because the query issued was

SELECT * FROM Account LIMIT 100;

with Account not double-quoted.

how can I set password for connection?

max@max-linux:~/Codes/go/pgweb$ pgweb --url postgresql://max:pass@localhost:5432/postgres
Connecting to server...
Error: missing "=" after "postgresql://max:pass@localhost:5432/postgres" in connection info string"

Extra scrollbars

In both Firefox and Chrome, extra scrollbars and shown in all panes, which look horrible.

The problem is that you are setting "overflow: scroll" on all the divs, which is dumb.

You should use "overflow: auto" instead.

Run query for selected text

When text is selected, only run the selected text as a query. Otherwise use the current behaviour, and run all entered text as a query.

I use the query tab as a scratchpad - adding queries or editing old ones as I navigate a problem. Currently I will comment out all other sql statments, run the query then comment it out and uncomment a different sql statement.

Content tab is not usable when table name contains hypen characters, underscores, whitespaces

I have table names with hypens, underscores, whitespace, etc. in them and I get the following error after starting pgweb, selecting a table with such characters in its name from the left column with "Database Tables" and clicking on the Content tab.

The following errors is displayed: ERROR: pq: syntax error at or near "-"

The table name and schema names should be quoted with double quotes " in PostgreSQL to denote identifiers.

See: http://www.postgresql.org/docs/9.3/static/sql-syntax-lexical.html

There is a second kind of identifier: the delimited identifier or quoted identifier. It is formed by enclosing an arbitrary sequence of characters in double-quotes ("). 

A delimited identifier is always an identifier, never a key word. 

So "select" could be used to refer to a column or table named "select", whereas an unquoted select would be taken as a key word and would therefore provoke a parse error when used where a table or column name is expected. 

The example can be written with quoted identifiers like this:

UPDATE "my_table" SET "a" = 5;

**Quoted identifiers can contain any character, except the character with code zero**. (To include a double quote, write two double quotes.) 

This allows constructing table or column names that would otherwise not be possible, such as ones containing spaces or ampersands. 

The length limitation still applies.

Overlap between table names in the "Database Tables" left column

There is an overlap of table names when there are table names that contains hypens, whitespaces, underscores, start with upper case letters, or contain upper case letters
or when the table names are longer that the width of the left box where the table names are displayed.

Mysql support

How against adding mysql support would you be? I find your tool very direct and to the point and mysql has nothing remotely like it (they don't even have an open source gui tool like pgadmin) so I think it would be pretty cool. I know that this would add a layer of compatibility and probably would make working with css/html morecomplex as you have to support both but it is so much better than working with phpmyadmin that I think you might gain a lot of users/contributors.

If you are interested I or someone looking at this can start a fork to add support in the hopes that it gets merged back.

ps: yes mysql is a worse database manager, please tell that to wordpress core :)

--ssl disable does not work

Maybe there is something wrong in the syntax, but this does not work

$ pgweb --ssl disable --url postgres://vc:[email protected]:5432/my_db
Connecting to server...
Error: pq: SSL is not enabled on the server

I'm using 0.3.0, Mac OS X

'make deps' fails due to undefined Asset in api.go

Hello,
I get the following error when trying to run 'make deps' on a fresh checkout.

go get

github.com/pgweb

./api.go:27: undefined: Asset
./api.go:156: undefined: Asset
make: *** [deps] Error 2

The issue is that Asset doesn't get defined until after running 'go-bindata ...' to generate the bindata.go file.

If you include the bindata.go that is generated from 'go-bindata -debug ...' in your project then everything will work and subsequent calls to 'make dev' or 'make build' will overwrite as expected.

Alternatively, you could include the 'go-bindata ... ' call as part of 'make deps', but then 'go get' will need to move down the chain.

AngularJS ?

I was thinking of angularifying the app, I think it would scale better. Would you be opposed ?

Error: Database does not have any tables ... but it does

I am trying to connect to a database running on another machine on the network. When I connect with pgAdmin it works perfectly, so I know that it should work.

I try to run pgweb with the following command:

 pgweb_windows_amd64.exe /url:"postgres://vagrant:[email protected]/mydbname"

Here is the error that it returns:

Connecting to server...
Checking tables...
Error: Database does not have any tables

I turned on connection logging on the server, and here is what I got:

2014-10-29 01:11:30 GMT 54503ec2.7ee9 vagrant mydbname LOG:  statement: SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_schema,table_name;
2014-10-29 01:11:30 GMT 54503ec2.7ee9 vagrant mydbname LOG:  could not receive data from client: Connection reset by peer

When I run that query (SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' ORDER BY table_schema,table_name;) in pgAdmin, it returns the list of tables, as expected.

What is causing this?

Is there any other information that can be used to troubleshoot?

CREATE TABLE should refresh table listing

When I use pgweb to run a CREATE TABLE command, the response is that no records were found (which makes sense, I wasn't retrieving anything with the query).

It would be cool if the tool could tell that I was creating a table, and refresh the table listing (and perhaps focus on the newly created table?).

Brew installing

Could it be possible to install (and keep updated) via homebrew?

Would be awesome to not depend on checking out Github from time to time for updating.

Uppercase table names must be quoted

This may be connected to both #29 and #16 (if not the same issue). I have a table that starts with a capital letter (eg: "Users") and if I try to do a query 'SELECT * FROM Users' it complains about there being no "users" table. However if I do 'SELECT * FROM "Users"' then it works.

I don't have a lot of experience with pgsql (come from a mysql background) and I rarely use uppercase in my table names (the ORM I'm using did it). The structure tab works just fine, it's just queries that are effected. Again, this may be expected behavior but I wanted to open an issue to make sure. Thanks!

Daemon Mode

An argument for forking pgweb to the background would be great

Keyboard support for SQL Query

Ability to work on a sql query with just the keyboard.

Didn't see a way to submit a query by keyboard shortcut (on OSX).

Great app by the way. Liking it better than pgAdmin already!

Bookmark server connections

Another great addition to the pgweb could be "bookmarked" connections. This will provide a way to
quickly server connection settings. Most native database managers do that and its very helpful.

Few options to consider:

Store bookmarks in cookie/localstorage

  • Pros: easy implementations
  • Cons: no real persistence

Store bookmarks in a local file

File could be something like ~/.pgweb_bookmarks. Not sure about how would this work on
Windows machines. As for file format, it could be either YAML or TOML. Im leaning towards
TOML since it has format very similar to INI files. However, JSON does really make sense to use,
its consumed by browser but it does not have great readability.

  • Pros: opens doors for more customizations, easy implementation
  • Cons: syntax/formatting

Proposed file format (TOML):

# If url is defined it takes precedence
url = "postgres://..."

# Regular server connection settings
host = "localhost"
port = 5432
user = "username"
database = "dbname"
ssl_mode = "disable"

Would like to get some feedback if anyone is interested.

Bookmark.Port expected string.

According to wiki, port in bookmark file should be int, but it fails with

Type mismatch for 'main.Bookmark.Port': Expected string but found 'int64'.

Passing it as string instead works fine.
Either wiki is wrong or code is wrong :-).

Listen IP

Hi, I'm trying to create a Dockerfile / Docker container to run pgweb in. My problem is that pgweb seems to bind to localhost and that there is no way to change this at the moment.

Would be great if you could specify listen port and listen IP to bind it to an IP.

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.