Command line database query utility for MySQL.
- Golang
mysqlshcommand line utility.
Docs may be generated with the docs command.
- Outputs to the
docsdirectory.
- MYSQL_SERVER
- MYSQL_USER
- MYSQL_PASS
- MYSQL_PORT
query
- Queries
MYSQL_SERVERusing the query file (and line number) specified in the arguments. - If the option to generate an output file is enabled, the output file will be by the same filename as the input file.
session
- Opens a database session with
MYSQL_SERVER. - All queries ran during the session are piped to a session file which is generated in the
.qdb-mysqlunder your user's home directory. - Session filenames are generated with a unique timestammp.
- While the session is open, you may run a query or queries from any file and/or line number.
This utility uses VSCode for some "glossy" functions.
- If you choose not to use VSCode, it is possible your editor can use the following features.
Features using VSCode:
- Piping commands into the terminal based on keyboard shortcuts and selected line number.
- See
.vscode/keybindings.json. - These settings will need to be installed in you user settings.
- Example installation location (MacOS):
/Users/<username>/Library/Application Support/Code/User/keybindings.json.
- Opening SQL results into a new editor tab.
- See
func openFile(file string) errorinsession.go. - This is done automatically after each query.
- If a tab is already opened
q ${file}:${lineNumber}
- Execute a query from a specific file
${file}, starting at line number${lineNumber}.
q+ ${file}:${lineNumber}
- Same as above, but reopen the session file upon execution.
q ${file}
- Execute all queries query from a specific file
${file}.
q+ ${file}
- Same as above, but reopen the session file upon execution.
- Leading comments are ran as empty queries instead of being extracted prior to execution.
- When querying by line number, trailing comments can cause execution to continue.
- To stop this, just use
;without any comments when delineating queries.
You might find that this code needs some tweaks to run with your specific system or to meet your specific needs.
- PRs are welcome, and encouraged!