#postgresql #sql-database #sql

app pgburst

A file-based way to edit postgresql databases (procedures, views, triggers) without GUI

4 releases

0.2.1 Jan 12, 2024
0.2.0 Jan 9, 2024
0.1.2 Jan 4, 2024
0.1.0 Dec 30, 2023

#761 in Database interfaces

40 downloads per month

GPL-3.0-only

290KB
642 lines

PgBurst

Extract functions, views, (composite or enum) types, sequences, and triggers from your postgres database into files for editing.

Introduction

While pgcli is wonderful to select and manipulate data and edit the occasional function, one can quickly get lost trying to edit triggers or functions or views in the many different schemas of complex databases.

While there are a number of excellent GUIs for editing postgres databases, they tend to take over the entire workflow, which can be a bummer if you work best with setups like i3, lf and nvim (or awesome, ranger and helix etc.)

pgburst extracts sql-files out of your database into folders organized by schema and type (function, trigger, view). Editing is then executed using your own choice of tools.

Installation

Cargo install pgburst

Archlinux

yay -S pgburst

Features

You can

  • extract all functions, views, (composite or enum) types, sequences, and triggers, or
  • those of selected schemas, or
  • those whose sql definition contains a specific text

etc., and edit these files using the workflow you work best with.

The gif below shows how just the one function is extracted from the example database "dvdrental" whose definition contains the word "sanity" (in a comment):

Show sanity

Keeping watch, the "-w" flag

pgburst can also watch the files for changes.

Flag -w starts pgburst so that altered files are executed against the database as soon as they are saved.

Show waiting

Usage

pgburst [OPTIONS] <DB_NAME> [OBJECTS_FILTER]

Arguments:
<DB_NAME> Name of the database to connect to

[OBJECTS_FILTER]... Only export items of the specified type(s) (list item types separated by space) [possible values: function, trigger, view, type, sequence]

Options:
-b, --burst-folder <BURST_FOLDER> Where to store the sql files. (Default is .)

--pg-user, user connecting to the database (default is postgres)

--pg-host, host to connect to (default is localhost)

-s, --schema-filter <SCHEMA_FILTER> Only export items of this schema or list of schemas (option can be used repeatedly to export more than one schema)

-n, --name-filter <NAME_FILTER> Only export items whose names contain the given text

-f, --find Only export items whose sql respresentation contains the given text

-w, --watch Watch the burst sql files for changes and execute them against the database (default: false). Cancel with C-c when you're done. Watching does not cover deletion or addition of files (yet?)!

Future

Next steps:

[x] Make connection string configurable (user, host) v0.1.2 [/] Add export of types [v0.2.0, no range or box types] [x] Add export of sequences v0.2.1 [ ] Add info on sequences in comments [ ] Add export of table [ ] Add update/insert scripts [ ] Add mode for querying through wait mode and an open file [ ] Add export of roles and privileges [ ] React to deletion of files (possibly also addition of files?)

Dependencies

~10–22MB
~360K SLoC