jakob / jakob/Postico

Custom Actions - make Postico extendable with scripts

Open
#105 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
486
Forks
8
PR merge metrics
No merged PRs in 30d

Description

It would be great if predefined custom SQL queries (snippets) could be executed in context of specific objects such as databases, tables and columns. I would envisage list of possible snippets/actions exposed in a context menu as per the below image.

![postico_actions](https://cloud.githubusercontent.com/assets/934664/10824523/af711886-7e58-11e5-9fa1-6b07dcc32599.png)

Let's say I would add the following snippet to the app, which I can use to duplicate a database:

``` sql
-- Create a new database using the given database as a template
CREATE DATABASE "{{database}}_new"
TEMPLATE = "{{database}}"
```

Here the `{{database}}` placeholder is a parameter to be replaced by the database name I have clicked on. The Postico would be clever enough to detect the `{{database}}` placeholder in the code and automatically offer the action in the context menu for databases.

Selecting such an action from the context menu could either bring the SQL editor with the pre-populated query with the placeholder parameters replaced appropriately or execute the query and show the result right away. Perhaps, there could be a checkbox for each custom SQL query to define this behaviour.

Having this feature would remove the burden of maintaining lists of SQL code snippets in files on the disk or in a separate app. Also, this would allow Postico to be extended with many missing features quite easily (such as listing sequences in the database).

Here's another example of such a snippet, which could be used in the context of a table column:

``` sql
-- Show records for which the given column is not a valid email address
SELECT * FROM {{database}}.{{table}}
WHERE {{column}} !~ '^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+[.][A-Za-z]+$'
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no files, tests, or entry points. Research must first locate the database, table, and column context-menu code; completion would require configurable SQL snippets with placeholder-based context selection and a choice between editor preview and immediate execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
databases
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.