From 28ebae4525f35672acd6253b3022bdb8cdc1cbd1 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Wed, 28 Feb 2018 21:32:48 +0000 Subject: Update readme. Fix result parsing bug. Rearrange files - Prefix query result fields with an underscore to avoid clashing with JS builtin property/function names which causes issues with Tabulator - Move html files into their own dir --- README.md | 43 ++++++++++++++++++++++- editor-instance.html | 45 ------------------------- editor-instance.js | 19 +++++++++-- html/editor-instance.html | 45 +++++++++++++++++++++++++ html/index.html | 26 ++++++++++++++ html/new-connection.html | 73 ++++++++++++++++++++++++++++++++++++++++ html/query-executor-wrapper.html | 7 ++++ index.html | 26 -------------- instance-manager.js | 2 +- main.js | 6 ++-- new-connection.html | 73 ---------------------------------------- query-executor-wrapper.html | 7 ---- styles/editor-instance.css | 15 +++++++++ 13 files changed, 229 insertions(+), 158 deletions(-) delete mode 100644 editor-instance.html create mode 100644 html/editor-instance.html create mode 100644 html/index.html create mode 100644 html/new-connection.html create mode 100644 html/query-executor-wrapper.html delete mode 100644 index.html delete mode 100644 new-connection.html delete mode 100644 query-executor-wrapper.html diff --git a/README.md b/README.md index 52a6337..260cb70 100644 --- a/README.md +++ b/README.md @@ -1 +1,42 @@ -# sql-plus-plus \ No newline at end of file +# SQL++ +[![Build Status](https://travis-ci.org/jamesbarnett91/sql-plus-plus.svg?branch=master)](https://travis-ci.org/jamesbarnett91/sql-plus-plus) + +A simple cross platform SQL editor and statement runner. +Currently for Postgres only, but MySQL and Oracle support planned. + +

+ VS Code in action +

+ +# Features +- Rich editor features. Syntax highlighting, autocomplete, bracket matching etc. +- Cross platform. Linux (.deb), Windows and MacOS binaries available. +- Simple editor interface. Doesn't have a huge array of GUI features like pgAdmin or Toad. For people who prefer a clean way to edit and run SQL. +- Sortable and resizable query results table. + +# Installation +Download one of the binary distributions from the releases page. +Or, to run locally: +```sh +$ git clone https://github.com/jamesbarnett91/sql-plus-plus && cd sql-plus-plus +$ npm install +$ npm start +``` + +# Roadmap +- [x] Store connection config +- [x] Handle multiple simultaneous connections +- [ ] Add schema tree view (listing tables>columns, packages, sequences etc.) +- [ ] Load/Save .sql files +- [ ] Improve autocomplete to be more schema aware +- [ ] Support MySQL +- [ ] Support Oracle +- [ ] Save and display query history +- [ ] CSV download of query results +- [ ] 'Interpreter' mode. Run single queries with a CLI type interface (like Postgres psql and Oracle SQL*Plus) +- [ ] Build .rpms + +# Note +This is just a personal project, and a work in progress. There might be a few bugs in the result parsing, so don't rely on it for anything important unless you enjoy living on the edge. + +Connection details (including passwords) are stored encrypted, but the key is in the source code so it's only a basic level of obfuscation. I wouldn't connect to any prod databases with this. \ No newline at end of file diff --git a/editor-instance.html b/editor-instance.html deleted file mode 100644 index 454c6ce..0000000 --- a/editor-instance.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - SQL++ - - - - - - - - - - - - -
-
- -
- - -
-
- -
-
-
-
-
- - -
- - - - \ No newline at end of file diff --git a/editor-instance.js b/editor-instance.js index 8ed6674..6e2fd67 100644 --- a/editor-instance.js +++ b/editor-instance.js @@ -188,7 +188,7 @@ function handleResult(results) { dataTable = $("#result-table").tabulator({ height: "100%", columns: _mapColumnProperties(results), - data: results.rows + data: _escapeRowFieldNames(results.rows) }); _setExecutionStatusIndicator("OK"); @@ -198,12 +198,27 @@ function handleResult(results) { function _mapColumnProperties(results) { return results.fields.map((column) => { return { - field: column.name, + field: "_" + column.name, // "_" to match up to the output of _escapeRowFieldNames() title: column.name }; }); } +/** + * Return the row object with all fields prefixed with an underscore. + * This avoids issues with Tabulator which doesn't like fields to have the same identifiers + * as built in JS properties/functions (e.g. 'length') + */ +function _escapeRowFieldNames(rows) { + return rows.map(row => { + let escapedRow = {} + Object.keys(row).forEach(key => { + escapedRow["_" + key] = row[key]; + }); + return escapedRow; + }); +} + function _resultTable() { return $("#result-table"); } diff --git a/html/editor-instance.html b/html/editor-instance.html new file mode 100644 index 0000000..eaa2599 --- /dev/null +++ b/html/editor-instance.html @@ -0,0 +1,45 @@ + + + + + + SQL++ + + + + + + + + + + + + +
+
+ +
+ + +
+
+ +
+
+
+
+
+ + +
+ + + + \ No newline at end of file diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..b1997bf --- /dev/null +++ b/html/index.html @@ -0,0 +1,26 @@ + + + + + SQL++ + + + + + + + +
+
+
+ +
+
+ +
+ + + + \ No newline at end of file diff --git a/html/new-connection.html b/html/new-connection.html new file mode 100644 index 0000000..192c9b9 --- /dev/null +++ b/html/new-connection.html @@ -0,0 +1,73 @@ + + + + + SQL++ - New connection + + + + + +

Add new connection

+
+
+ +
+ +
+

This is shown as the title of the connection tab

+
+
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ + + \ No newline at end of file diff --git a/html/query-executor-wrapper.html b/html/query-executor-wrapper.html new file mode 100644 index 0000000..ddc9ffc --- /dev/null +++ b/html/query-executor-wrapper.html @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/index.html b/index.html deleted file mode 100644 index 2d8dbee..0000000 --- a/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - SQL++ - - - - - - - -
-
-
- -
-
- -
- - - - \ No newline at end of file diff --git a/instance-manager.js b/instance-manager.js index 96151ab..2debb57 100644 --- a/instance-manager.js +++ b/instance-manager.js @@ -13,7 +13,7 @@ function createNewConnection() { function registerNewInstance(payload) { tabGroup.addTab({ title: getTabTitle(payload.connectionConfig), - src: "file://" + __dirname + "/editor-instance.html", + src: "file://" + __dirname + "/html/editor-instance.html", visible: true, active: true, webviewAttributes: {"nodeintegration":true}, diff --git a/main.js b/main.js index e7f0e44..d211c1e 100644 --- a/main.js +++ b/main.js @@ -20,7 +20,7 @@ function createMainWindow() { height: 600 }); uiWindow.loadURL(url.format({ - pathname: path.join(__dirname, "index.html"), + pathname: path.join(__dirname, "html", "index.html"), protocol: "file:", slashes: true })); @@ -54,7 +54,7 @@ function createNewConnectionDialog() { height: 600 }); newConnectionDialog.loadURL(url.format({ - pathname: path.join(__dirname, "new-connection.html"), + pathname: path.join(__dirname, "html", "new-connection.html"), protocol: "file:", slashes: true })); @@ -79,7 +79,7 @@ function createQueryExecutor(payload) { console.log("created executor with id:" + executor.executorId); executor.loadURL(url.format({ - pathname: path.join(__dirname, "./query-executor-wrapper.html"), + pathname: path.join(__dirname, "html", "query-executor-wrapper.html"), protocol: "file:", slashes: true })); diff --git a/new-connection.html b/new-connection.html deleted file mode 100644 index ddfb380..0000000 --- a/new-connection.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - SQL++ - New connection - - - - - -

Add new connection

-
-
- -
- -
-

This is shown as the title of the connection tab

-
-
- -
-
- -
-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
-
- -
-
- -
-
- -
-
-
- - - \ No newline at end of file diff --git a/query-executor-wrapper.html b/query-executor-wrapper.html deleted file mode 100644 index 68c0356..0000000 --- a/query-executor-wrapper.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/styles/editor-instance.css b/styles/editor-instance.css index 7ae5727..cb3aa95 100644 --- a/styles/editor-instance.css +++ b/styles/editor-instance.css @@ -130,4 +130,19 @@ body { .statement-pointer { width: 10px; +} + +.button { + padding: 4px 6px; + background: #6D8A88; + border: none; + border-radius: 2px; + font-size: 12px; + margin: 6px; + text-align: center; +} + +.button:hover { + color: #eee; + background-color: #aaa; } \ No newline at end of file -- cgit v1.2.3