Skip to content
This repository was archived by the owner on Aug 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SqlPad

A Node.js web app for writing and running SQL queries and visualizing the results. Supports Postgres, MySQL, and SQL Server.
A Node.js web app for writing and running SQL queries and visualizing the results. Supports Postgres, MySQL, SQL Server and Vertica.

![SqlPad Query Editor](screenshots/query-editor.png)

Expand Down
23 changes: 22 additions & 1 deletion lib/run-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,25 @@ clients.sqlserver = function (query, connection, callback) {
});
}
});
};
};

clients.vertica = function (query, connection, callback) {

var connectionUrl = "postgres://" + connection.username
+ ":" + connection.password
+ "@" + connection.host
+ "/" + connection.database;

var client = new pg.Client(connectionUrl);
client.connect(function (err) {
if (err) {
callback(err);
client.end();
} else {
client.query(query, function(err, result) {
callback(err, result);
client.end();
});
}
});
}
24 changes: 18 additions & 6 deletions routes/schema-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@ module.exports = function (app) {
connection.username = decipher(connection.username);
connection.password = decipher(connection.password);

var tableAndColumnSql = "SELECT t.table_type, t.table_schema, t.table_name, c.column_name, c.data_type, c.is_nullable "
+ " FROM INFORMATION_SCHEMA.tables t "
+ " JOIN INFORMATION_SCHEMA.columns c ON t.table_schema = c.table_schema AND t.table_name = c.table_name "
+ " WHERE t.table_schema NOT IN ('information_schema', 'pg_catalog') "
+ " ORDER BY t.table_type, t.table_schema, t.table_name, c.ordinal_position ";
if (connection.driver !== "vertica") {

var tableAndColumnSql = "SELECT t.table_type, t.table_schema, t.table_name, c.column_name, c.data_type, c.is_nullable "
+ " FROM INFORMATION_SCHEMA.tables t "
+ " JOIN INFORMATION_SCHEMA.columns c ON t.table_schema = c.table_schema AND t.table_name = c.table_name "
+ " WHERE t.table_schema NOT IN ('information_schema', 'pg_catalog') "
+ " ORDER BY t.table_type, t.table_schema, t.table_name, c.ordinal_position";
} else {
var tableAndColumnSql = "SELECT (CASE vat.table_type WHEN 'TABLE' THEN 'BASE TABLE' ELSE 'TABLE' END) AS table_type, "
+ " vt.table_schema, vt.table_name, vc.column_name, vc.data_type, "
+ " (CASE vc.is_nullable WHEN 't' THEN 'YES' ELSE 'NO' END) as is_nullable "
+ " FROM V_CATALOG.TABLES vt "
+ " JOIN V_CATALOG.ALL_TABLES vat ON vt.table_id = vat.table_id "
+ " JOIN V_CATALOG.COLUMNS vc ON vt.table_schema = vc.table_schema AND vt.table_name = vc.table_name "
+ " WHERE vt.table_schema NOT IN ('V_CATALOG') AND vat.table_type = 'TABLE' "
+ " ORDER BY vat.table_type, vt.table_schema, vt.table_name, vc.ordinal_position";
}

var tree = {};

Expand Down Expand Up @@ -62,4 +74,4 @@ module.exports = function (app) {

});
});
};
};
3 changes: 2 additions & 1 deletion views/connection.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<option value="mysql" <%= (connection.driver === 'mysql' ? 'selected' : '') %> >MySQL</option>
<option value="postgres" <%= (connection.driver === 'postgres' ? 'selected' : '') %>>Postgres</option>
<option value="sqlserver" <%= (connection.driver === 'sqlserver' ? 'selected' : '') %>>SQL Server</option>
<option value="vertica" <%= (connection.driver === 'vertica' ? 'selected' : '') %>>Vertica</option>
</select>
</div>
</div>
Expand Down Expand Up @@ -74,4 +75,4 @@



<% include footer %>
<% include footer %>