All Projects → joereynolds → Sqhell.vim

joereynolds / Sqhell.vim

Licence: mit
An SQL wrapper for vim

Projects that are alternatives of or similar to Sqhell.vim

Vscode Sqltools
Database management for VSCode
Stars: ✭ 741 (+555.75%)
Mutual labels:  sql, mysql, sqlite, postgres, sqlite3
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+1021.24%)
Mutual labels:  sql, mysql, sqlite, postgres, sqlite3
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+6724.78%)
Mutual labels:  sql, mysql, sqlite, postgres
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+1769.03%)
Mutual labels:  sql, mysql, sqlite, postgres
Ebean
Ebean ORM
Stars: ✭ 1,172 (+937.17%)
Mutual labels:  sql, mysql, sqlite, postgres
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (+49.56%)
Mutual labels:  sql, mysql, sqlite, sqlite3
Atdatabases
TypeScript clients for databases that prevent SQL Injection
Stars: ✭ 154 (+36.28%)
Mutual labels:  sql, mysql, sqlite, postgres
Walkable
A Clojure(script) SQL library for building APIs: Datomic® (GraphQL-ish) pull syntax, data driven configuration, dynamic filtering with relations in mind
Stars: ✭ 384 (+239.82%)
Mutual labels:  sql, mysql, sqlite, sqlite3
Requery
requery - modern SQL based query & persistence for Java / Kotlin / Android
Stars: ✭ 3,071 (+2617.7%)
Mutual labels:  sql, mysql, sqlite, postgres
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+1948.67%)
Mutual labels:  sql, mysql, sqlite, postgres
Sqlx
🧰 The Rust SQL Toolkit. An async, pure Rust SQL crate featuring compile-time checked queries without a DSL. Supports PostgreSQL, MySQL, SQLite, and MSSQL.
Stars: ✭ 5,039 (+4359.29%)
Mutual labels:  sql, mysql, sqlite, postgres
Goqu
SQL builder and query library for golang
Stars: ✭ 984 (+770.8%)
Mutual labels:  sql, mysql, sqlite, postgres
Smartsql
SmartSql = MyBatis in C# + .NET Core+ Cache(Memory | Redis) + R/W Splitting + PropertyChangedTrack +Dynamic Repository + InvokeSync + Diagnostics
Stars: ✭ 775 (+585.84%)
Mutual labels:  sql, mysql, sqlite
Usql
Universal command-line interface for SQL databases
Stars: ✭ 6,869 (+5978.76%)
Mutual labels:  sql, mysql, sqlite3
Xorm
Simple and Powerful ORM for Go, support mysql,postgres,tidb,sqlite3,mssql,oracle, Moved to https://gitea.com/xorm/xorm
Stars: ✭ 6,464 (+5620.35%)
Mutual labels:  mysql, sqlite, postgres
Eosio sql plugin
EOSIO sql database plugin
Stars: ✭ 21 (-81.42%)
Mutual labels:  sql, mysql, sqlite
Ezsql
PHP class to make interacting with a database ridiculusly easy
Stars: ✭ 804 (+611.5%)
Mutual labels:  sql, mysql, sqlite3
Go Structured Query
Type safe SQL query builder and struct mapper for Go
Stars: ✭ 101 (-10.62%)
Mutual labels:  sql, mysql, postgres
Sequelize
An easy-to-use and promise-based multi SQL dialects ORM tool for Node.js
Stars: ✭ 25,422 (+22397.35%)
Mutual labels:  sql, mysql, sqlite
East
node.js database migration tool
Stars: ✭ 53 (-53.1%)
Mutual labels:  mysql, sqlite, postgres

SQHell.vim

An SQL wrapper for Vim. Execute commands, sort results, navigate tables and databases and so much more!

The supported providers at the moment are

  • MySQL
  • Postgres
  • Sqlite

It started off simply enough:

nnoremap <leader>xc :r !mysql -uroot -psomepass -h somehost.com <<< `cat %` \| column -t<cr>

It grew from there...

Examples

(Gifs are using the data from my band bogans)

Execute a command using SQHExecute!

Execute a line with SQHExecute.

Execute a visual block with SQHExecute over a visual selection.

Execute an arbitrary command with SQHExecute!.

Execute a file using SQHExecuteFile

SQHExecuteFile will work on the current buffer if no file is supplied

Explore the database with buffer aware mappings

Installation

Vim Plug

Plug 'joereynolds/SQHell.vim'

Configuration

Connection details will need to be supplied in order for SQHell.vim to connect to your DBMS of choice. The connections are in a dictionary to let you manage multiple hosts. By default SQHell uses the 'default' key details (no surprise there)

Example:

let g:sqh_provider = 'psql'

let g:sqh_connections = {
    \ 'default': {
    \   'user': 'root',
    \   'password': 'testing345',
    \   'host': 'localhost'
    \},
    \ 'live': {
    \   'user': 'root',
    \   'password': 'jerw5Y^$Hdfj',
    \   'host': '46.121.44.392'
    \}
\}

You can use the SQHSwitchConnection function to change hosts. i.e. SQHSwitchConnection live

SQHell currently supports 3 providers and fallsback to MySQL if none specificed.

The 3 providers are:

  • mysql - A connection to a MySQL DB. Specify it with let g:sqh_provider = 'mysql'

  • psql - A connection to a Postgres DB. Specify it with let g:sqh_provider = 'psql'

  • sqlite - A connection to a Sqlite DB. Specify it with let g:sqh_provider = 'sqlite'

I strongly suggest that the above configuration details are kept outside of version control and gitignored in your global gitignore.

Default Keybindings

SQHell creates 3 filetypes to make navigation a nicer experience. These are SQHDatabase, SQHTable, and SQHResult

SQHDatabase

Inside an SQHDatabase you can press the following

dd - Drop the database (don't worry there's a prompt).

e - To see all the tables in that database. This will open an SQHTable buffer.

SQHTable

Inside an SQHDatabase you can press the following

dd - Drop the table (don't worry there's a prompt).

e - To see all the results for that table with a limit of g:sqh_results_limit. This will open an SQHResult buffer

SQHResult

Inside an SQHResult you can press the following

s to sort results by the column the cursor is on.

S to sort results by the column the cursor is on (in reverse).

dd to delete the row WHERE the column is the value under the cursor (don't worry... there's a prompt).

e to edit the current row. This will open an SQHInsert buffer

For more sorting options, you can use :SQHSortResults with extra arguments for the unix sort command, a la :SQHSortResults -rn. It will always sort by the column the cursor is located on.

SQHInsert

Inside an SQHInsert you can press the following

ZZ to close and save the edited row. This will reopen the previous SQHResult buffer

Contributing

Please see the Contributing guidelines if you would like to make SQHell even better!

Tests

Tests use vader.

Tests are housed in the test directory and can be ran by viming into the test file and running :Vader.

What about dbext, vim-sql-workbench and others?

DBExt is very featureful (and very good) but comes in at a whopping 12000 lines of code. By contrast SQHell.vim is a mere ~200 lines

The setup and installation process for vim-sql-workbench is something that I aim to avoid with SQHell.vim, ideally a 'set and forget' plugin.

There are no clever inferences inside SQHell.vim.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].