Skip to content
v420vPublic

About

A lightweight desktop database client written in Go.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PixelRow

A lightweight desktop database client written in Go.

PostgreSQL    MySQL    MariaDB    CockroachDB    SQLite    Redis

PixelRow running a query, with the connection tree on the left and the result below the editor

Note

PixelRow is still small and has a lot of growing to do. It is developed on macOS, there are no prebuilt downloads yet, and things will change.

Features

  • Connections: PostgreSQL, MySQL, MariaDB, CockroachDB, SQLite and Redis, several open at once, each in its own tabs, read from a TOML file.
  • Search: narrow the tree down by the name of a connection, a database or a table.
  • SQL editor: syntax highlighting, and completion for tables, columns and aliases.
  • Running queries: the selection or the statement at the caret with Cmd+Enter, everything with Cmd+Shift+Enter. Rows load as you scroll, and a running query can be cancelled.
  • Tables: data, columns, indexes, foreign keys and DDL. Cells and rows can be edited where the table has a primary key.
  • Foreign keys: in the rows of a table, point at a cell of a foreign key and press the arrow that shows to open the row it refers to.
  • Value panel: the whole value of a cell beside the rows, for what one line of the grid cuts short. JSON is laid out and highlighted.
  • Copy and export: copy the cells chosen with Cmd+C to paste into a spreadsheet, or as CSV or JSON from their menu. Export writes every row of a result to a CSV or JSON file, not only those loaded so far: it runs the query again on a session of its own.
  • Diagrams: an entity-relationship diagram of a schema, or of one table and what refers to it.
  • Dump and SQL files: dump with pg_dump, mysqldump, mariadb-dump or sqlite3, and run a SQL file with psql, mysql, mariadb or sqlite3.
  • SSH tunnels: reach a database behind a bastion through your own ssh.
  • Color and read-only: mark a connection with a color, and keep the app from writing to it.

Entity-relationship diagram of a schema

Getting started

You need Go 1.27 or later.

git clone https://github.com/v420v/pixelrow.git
cd pixelrow
go tool mygo dev      # run it, reloading as the code changes
go tool mygo build    # package it as an app into build/

On the first start PixelRow creates ~/.config/pixelrow/config.toml with commented examples. Add a connection and press Reload:

[connections.local]
kind = "postgres"       # or "mysql", "mariadb", "cockroach", "sqlite" or "redis"; postgres when left out
host = "127.0.0.1"
port = 5432
user = "postgres"
password = "postgres"
database = "postgres"

Want something to connect to? The repository has a compose.yaml with two PostgreSQL servers, a MySQL server, a MariaDB server, a CockroachDB server, a Redis server and a SQLite file, filled with tables of every sort, and a config file with the connections to them:

docker compose up -d --wait
chmod 600 dev/pixelrow/config.toml
XDG_CONFIG_HOME="$PWD/dev" go tool mygo dev

Every docker compose up -d puts the databases back to that data, whatever was done to them in between.

Configuration

The file is at $XDG_CONFIG_HOME/pixelrow/config.toml, or ~/.config/pixelrow/config.toml. Each [connections.<name>] table is one connection.

A SQLite database is a file, so its connection has a path in place of a host:

[connections.notes]
kind = "sqlite"
path = "~/Documents/notes.db"   # a path that does not start at / or ~ starts at the config file's folder

The file must be there already: PixelRow does not make a database of a path that is misspelled.

Warning

Passwords are stored in this file as plain text. PixelRow creates it readable by you alone (0600), and refuses to read it with any other permissions.

Redis

Redis has neither tables nor SQL, so PixelRow shows it in the shape of what has:

[connections.cache]
kind = "redis"
host = "127.0.0.1"
password = "secret"   # with user, where the server has users
database = "0"        # the number of the database to start in
  • The tree lists the numbered databases that hold a key, db0 and up, and in each the ways its keys start: user:* stands for user:1, user:2:name and every other key that starts with user:. * is every key.
  • Opening one lists its keys with their type, the seconds they have left, how much they hold and the start of their value. The keys are read a page at a time with SCAN, never all at once.
  • A query is commands as redis-cli takes them, one to a line: HGETALL user:7. Quote what has spaces, and end a command with ; to run the one under the caret alone.
  • SHOW KEYS [pattern] [IN database] is PixelRow's own: it is what opening an item of the tree runs.
  • A connection with readonly = true asks the server what each command does, and runs only those that read. Scripts are refused, as they can do anything.

Keys are not edited in the grid, and there are no dumps: use the commands. Cluster and Sentinel are not there yet.

Color and read-only

[connections.production]
host = "db.example.com"
user = "app"
password = "secret"
database = "app"
color = "#dc2626"       # #rgb or #rrggbb
readonly = true

Options

Anything else the driver takes when it connects goes in an options table, under the driver's own names.

[connections.production.options]
sslmode = "verify-full"
sslrootcert = "~/certs/ca.pem"
connect_timeout = 10
statement_timeout = "30s"
  • PostgreSQL and CockroachDB: the connection parameters that pgx knows, such as sslmode, sslrootcert, sslcert, sslkey, connect_timeout and target_session_attrs. Any other name is a setting of the session, such as search_path or statement_timeout.
  • Redis: tls, as true, or skip-verify to encrypt without checking the certificate.
  • SQLite: its PRAGMAs, such as busy_timeout and journal_mode. Foreign keys are checked unless foreign_keys = "off" says otherwise.
  • MySQL and MariaDB: the parameters of the Go driver, such as tls (true, skip-verify, preferred), charset, collation and timeout, and ssl-ca, ssl-cert and ssl-key for certificate files. Any other name is a system variable of the session, such as sql_mode.

Dumps and SQL files connect with the same options, except that the programs of MySQL and MariaDB only take the ones about TLS, and need ssl-ca to check a certificate. host, port, user, password and database stay on the connection itself, and readonly cannot be lifted from here.

SSH tunnel

host is the database as the SSH server sees it.

[connections.production]
host = "db.internal"
user = "app"
password = "secret"
database = "app"

[connections.production.ssh]
host = "bastion.example.com"
user = "me"
port = 22                     # ssh's own default when left out
key = "~/.ssh/id_ed25519"     # ssh picks a key itself when left out
passphrase = "..."            # when the key has one
password = "..."              # when the server asks for one as well

A host that is already set up in ~/.ssh/config takes one line: ssh = "bastion". The server's host key must be known already, so connect to a new bastion once from a terminal first.

Tools

PixelRow looks for pg_dump, psql, mysqldump, mysql, mariadb-dump, mariadb, sqlite3 and ssh on your PATH and in the usual Homebrew, Postgres.app and Nix places. Tell it where they are when it does not find them:

[tools]
pg_dump = "/opt/homebrew/opt/libpq/bin/pg_dump"
psql = "/opt/homebrew/opt/libpq/bin/psql"
mysqldump = "/opt/homebrew/opt/mysql-client/bin/mysqldump"
mysql = "/opt/homebrew/opt/mysql-client/bin/mysql"
mariadb-dump = "/opt/homebrew/opt/mariadb/bin/mariadb-dump"
mariadb = "/opt/homebrew/opt/mariadb/bin/mariadb"
sqlite3 = "/opt/homebrew/opt/sqlite/bin/sqlite3"

CockroachDB is dumped with pg_dump and runs SQL files with psql. pg_dump must be at least the version of PostgreSQL the server gives as its own, which is 18 for CockroachDB 26, and a server too old to answer pg_dump cannot be dumped. To run such a dump, check "Keep going after a statement fails": it creates the schema public, which is there already. A hash-sharded index does not come back from it, and a dump cannot drop what it creates.

SQLite is dumped, and runs SQL files, with sqlite3 3.37 or later, which macOS comes with. It runs in its safe mode, where a file cannot run a program or open another database, and a file that fails is undone only as far as it opened a transaction itself, as a dump does.

A MariaDB server also answers a connection of kind mysql, but is dumped with MariaDB's own programs only as kind mariadb: mysqldump asks it for tables it does not have.

Contributing

Issues and pull requests are welcome.

The PostgreSQL, MySQL, MariaDB, CockroachDB, SQLite and Redis logos are trademarks of their owners and are used only to tell connections apart. See internal/app/logos.

About

A lightweight desktop database client written in Go.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages