{"id":30138453,"url":"https://github.com/cespedes/sqlvi","last_synced_at":"2026-04-17T05:03:12.588Z","repository":{"id":97435725,"uuid":"492257301","full_name":"cespedes/sqlvi","owner":"cespedes","description":"View and edit SQL entries using a text editor","archived":false,"fork":false,"pushed_at":"2022-06-03T13:53:54.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-11T01:24:38.992Z","etag":null,"topics":["database","postgres","postgresql","sql"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cespedes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-14T15:40:12.000Z","updated_at":"2022-06-03T14:37:26.000Z","dependencies_parsed_at":"2023-03-13T16:13:51.180Z","dependency_job_id":null,"html_url":"https://github.com/cespedes/sqlvi","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cespedes/sqlvi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cespedes%2Fsqlvi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cespedes%2Fsqlvi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cespedes%2Fsqlvi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cespedes%2Fsqlvi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cespedes","download_url":"https://codeload.github.com/cespedes/sqlvi/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cespedes%2Fsqlvi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31915900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"online","status_checked_at":"2026-04-17T02:00:06.879Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","postgres","postgresql","sql"],"created_at":"2025-08-11T01:14:22.847Z","updated_at":"2026-04-17T05:03:10.556Z","avatar_url":"https://github.com/cespedes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"sqlvi is used to view and modfy a SQL database from a text editor.\n\nIn order to do it, `sqlvi` performs a SQL query\nand displays its result as a text file,\nand launches an editor for the user.\nAfter the editor finishes, it calculates if there are changes\nand, if there are any,\nit updates the database accordingly.\n\nIn this state, it only works with PostgreSQL databases.\n\n## Details\n\nWhen `sqlvi` executes, it does the following:\n- Handle command-line arguments\n- Read configuration file\n- Connects to SQL database\n- Executes SQL query\n- Displays SQL result as a text-mode representation (text table, key-value fields...)\n- Launches an editor for the user to see and modify the text table\n- After the editor finishes, it finds the altered rows\n- In a transaction, it inserts, updates, or deletes rows from the database\n\nThe SQL queries that `sqlvi` executes can be specified from command line or\nin the configuration file.\n\nThe first field in the results must be unique and not null\n(it is typically a primary key).\nThis field should not be modified from the editor.\n\nWhen a row is modified, it executes an **update**.  \nWhen a row is deleted, it executes a **delete**.  \nWhen the user inserts a new row, with the first field empty, it executes an **insert**.\n\n## Command-line arguments\n\nThe general usage of `sqlvi` is:\n\n    sqlvi [options] [ \u003cmode\u003e ]\n\nThe `\u003cmode\u003e`, if given, specifies what set of options from the configuration file should\nbe applied.\n\nThe possible options are:\n\n- `-debug`: enable debugging info.  Not very useful,\n  unless you are debugging errors in the code.\n- `-config \u003cstring\u003e`: configuration file to read.\n  If not specified, it reads `.sqlvirc` from the user's\n  home directory.\n- `-output \u003cstring\u003e`: specify how to convert results to text, and vice versa.\n  Possible values are\n  `org` (Org-mode style text table, default),\n  `ini` (Windows INI file)\n  and\n  `ldap` (paragraphs with \"key: value\" pairs).\n- `-connect \u003cstring\u003e`: connection string to the database.\n  Right now it can only be user with PostgreSQL databases.\n- `-editor \u003cstring\u003e`: editor to use.  If not specified\n  (and not found in the configuration file), it tries `$VISUAL`,\n  `$EDITOR`, `editor`, `vim` and `vi`, in that order.\n- `-select \u003cstring\u003e`: Database query to execute on startup and\n  display its result.\n- `-insert \u003cstring\u003e`: Database query to add a new row.\n- `-update \u003cstring\u003e`: Database query to update a row.\n- `-delete \u003cstring\u003e`: Database query to delete a row.\n\nIn the `insert`, `update` and `delete` entries there can be arguments\nspecified as `$1`, `$2`, `$3`... which will be replaced by those\ncolumns in the modified row.  It is not needed to specify all the columns, or to\nhave them in the same order they appear.  They can also be repeated.\n\n## Configuration file\n\n`sqlvi` reads a YAML file (`$HOME/.sqlvirc` by default) similar to this:\n\n    editor: vim\n    connect: postgres://user:pass@host/database\n    default: countries\n    format: org\n    modes:\n      countries:\n        connect: postgres://user:pass@host/database\n        select: SELECT id,country,capital,language FROM countries\n        insert: INSERT INTO countries (country,capital,language) VALUES ($2,$3,$4)\n        update: UPDATE countries SET country=$2,capital=$3,language=$4 WHERE id=$1\n        delete: DELETE FROM countries WHERE id=$1\n      products:\n        connect: postgres://user:pass@host/database\n        select: SELECT id,name,price FROM products\n        insert: INSERT INTO products (name,price) VALUES ($2,$3)\n        update: UPDATE products SET name=$2,price=$3 WHERE id=$1\n        delete: DELETE FROM product WHERE id=$1\n\nThe configuration file is optional;\neverything can be specified from command line,\nwhich takes precedence over everything in this file.\nThe command-line arguments take precedenve over everything in the configuration file.\n\n## Text output\n\nThere are several ways to display the query result in text, depending on\nthe value of the `output` configuration parameter.\n\n### Org-mode table\n\nIf the `output` configuration parameter is `org`,\nthe results are rendered as a text table with this layout:\n\n    |----+---------+---------+----------|\n    | id | country | capital | language |\n    |----+---------+---------+----------|\n    | 1  | Spain   | Madrid  | Spanish  |\n    | 2  | Germany | Berlin  | German   |\n    | 3  | France  | Paris   | French   |\n    |----+---------+---------+----------|\n\nIt should have these lines, and in this order:\n- 0 or more lines that do not contain `|---` (which will be ignored).\n- A separator line, beginning with `|---`.\n- A line with list of column names, beginning and ending with `|` and separated by `|`.\n- A separator line, beginning with `|---`.\n- A line for each row, beginning and ending with `|`, and with values separated by `|`.\n  The first field should be unique and non-empty.\n- A separator line, beginning with `|---`.\n- 0 or more lines after that one (ignored).\n\n### INI file\n\nIf the `output` configuration parameter is `ini`,\nthe results are rendered as a INI-like file with this layout:\n\n    [1]\n    country = Spain\n    capital = Madrid\n    language = Spanish\n\n    [2]\n    country = Germany\n    capital = Berlin\n    language = German\n\n    [3]\n    country = France\n    capital = Paris\n    language = French\n\nThe order of the entries and the order of the fields in an entry is irrelevant.\n\nAn entry can be deleted or modified.\n\nA new entry can be created using `[]` as section.\n\n### YAML-like file\n\nIf the `output` configuration parameter is `ldap` or `yaml`,\nthe results are rendered as a list of paragraphs with `key: value` lines,\nsimilar to YAML or the LDIF format using in LDAP:\n\n    id: 1\n    country: Spain\n    capital: Madrid\n    language: Spanish\n\n    id: 2\n    country: Germany\n    capital: Berlin\n    language: German\n\n    id: 3\n    country: France\n    capital: Paris\n    language: French\n\nThe order of the entries is irrelevant.\nThe first field in an entry should be the primary key (`id` in the example),\nbut the order of the rest of the fields is irrelevant.\n\nAn entry can be deleted or modified.\n\nA new entry can be created using an empty value for the first key.\n\n## Actions\n\nAfter the editor finishes, `sqlvi` parses the text; if there are any errors,\nit displays them and asks the user what to do (edit the file again, or quit).\n\nIf there are no errors, it finds out what lines, if any, have been modified.\n\nIf there are no modified lines, it shows `No changes.` and exits.\n\nOtherwise, it displays a summary of changes, with the number of added,\nupdated and deleted lines, and asks the user what to do (edit the file again,\ncommit changes, or quit).\n\nIf the query to the database fails, it shows the error and asks the user again\nwhat to do: edit the file again, or quit.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcespedes%2Fsqlvi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcespedes%2Fsqlvi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcespedes%2Fsqlvi/lists"}