GithubHelp home page GithubHelp logo

sqlectron-core's Introduction

Slack Status Build


A simple and lightweight SQL client with cross database and platform support.

Demo (version 1.0.0)

demo

  • Databases - List of current supported databases.
  • Download - Installers, binaries and source.
  • Configuration - List of saved servers and custom configurations.
  • App Docs - Helper docs about the app.
  • Terminal - A terminal-based interface of Sqlectron.
  • Contribute - Details on how you can contribute to Sqlectron.

How to pronounce

It is pronounced "sequel-eck-tron" - https://translate.google.com/?source=osdd#en/en/sequel-eck-tron

sqlectron-core's People

Contributors

amilajack avatar barneydmedia avatar bornap avatar ckee83 avatar dependabot[bot] avatar derekchan avatar emerzh avatar felipetoffolo1 avatar jleclanche avatar kas avatar krolow avatar lebalz avatar luisrudge avatar marcbachmann avatar masterodin avatar maxcnunes avatar thomaspet avatar vitaly-t avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sqlectron-core's Issues

Fix failing test for mysql 8

  1) db
       mysql
         given is already connected
           .getTableCreateScript
             should return table create script:
     AssertionError: expected 'CREATE TABLE `users` (\n  `id` int NOT NULL AUTO_INCREMENT,\n  `username` varchar(45) DEFAULT NULL,\n  `email` varchar(150) DEFAULT NULL,\n  `password` varchar(45) DEFAULT NULL,\n  `role_id` int DEFAULT NULL,\n  `createdat` datetime DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  KEY `role_id` (`role_id`),\n  CONSTRAINT `users_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci' to include 'CREATE TABLE `users` (\n  `id` int(11) NOT NULL AUTO_INCREMENT,\n  `username` varchar(45) DEFAULT NULL,\n  `email` varchar(150) DEFAULT NULL,\n  `password` varchar(45) DEFAULT NULL,\n  `role_id` int(11) DEFAULT NULL,\n  `createdat` datetime DEFAULT NULL,\n  PRIMARY KEY (`id`),\n  KEY `role_id` (`role_id`),\n  CONSTRAINT `users_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE\n) ENGINE=InnoDB'
      at Context.<anonymous> (spec/db.spec.js:307:39)
      at Generator.next (<anonymous>)
      at step (spec/db.spec.js:31:191)
      at /home/runner/work/sqlectron-core/sqlectron-core/spec/db.spec.js:31:361
      at process._tickCallback (internal/process/next_tick.js:68:7)

Incorrect encryption/decryption methods

This is for v1.29.0

In the config passwords are encrypted and decrypted using crypto.createCipher using the aes-256-ctr algorithm. The nodejs documentation says this is incorrect:

Users should not use ciphers with counter mode (e.g. CTR, GCM, or CCM) in crypto.createCipher().

They suggest using crypto.createCipheriv() instead for this method of encryption, which requires we store the iv value as well. Otherwise we could just use a different encryption algorithm and leave it at that.

The reason I post this isn't necessarily that it's insecure, but that I want to create the config using a python script, but the python PyCrypto library requires an iv, but I haven't found what nodejs actually uses for it's iv value in this case, so I don't have a way of encrypting the passwords the same way node does.

Any response about a workaround at least would be great.

Fetching table keys

I went on writing support for fetching table keys so we can put key icon (for example) next to primary/foreign keys on diagram (so it would make more sense) or even on the column listing in the sidebar. In short we need names of columns which are foreign and primary keys.

So here are the possibilities how to implement that:

  1. Integrate it in listTableColumns method and add one more attribute to returning value. - Easiest and it's not breaking change. However this requires at least one extra join which makes query a bit slower. Not much slower, but since we use this on collapsing table sub menu, user might feel it's a bit laggy. Pro: We could show key icon next to columns name in database list (like in SQL Server studio). Con: Slows down fetching (only) table columns names.
  2. Change getTableReferences method so that it returns object containing referenced table (as it does now) and additionally column name and key type. For primary key referenced table would be null. This is option I feel most intuitive because we are reading it from the same table(s). This way we could show table keys under separate table sub menu (name Keys or something like that). It's the way all three major clients work - Workbench, pgAdmin and SQL Server studio. Pro: Good approach. Con: It's a breaking change.
  3. Make new method - getTableKeys and call it whenever we need (diagram, keys sub menu, on listing column names...). Pro: Flexibility I guess...

@maxcnunes Your two cents, which option to go with?

sqlserver regression on select query with cast

Query in question: SELECT CAST(GETDATE() AS DATE) throws the following error:

TypeError: Cannot read property 'reduce' of undefined

which happens on this line:

const affectedRows = result.affectedRows.reduce((a, b) => a + b, 0);

This should be altered to read:

const affectedRows = result.affectedRows ? result.affectedRows.reduce((a, b) => a + b, 0) : 0;

with appropriate test added here (and for the other adapters as well).

Fix failing tests for Cassandra 3.11

Looks like they changed the syntax of error messages between 3.7 and 3.11. Need to go through and verify what the new behavior is, and make it cross-version compatible so that 3.7 (or 3.0) and 3.11 both pass the test suite.

Error messages from test suite:

  1) db
       cassandra
         given is already connected
           .executeQuery
             SELECT
               should execute multiple queries:
     AssertionError: expected 'line 3:18 mismatched input \'select\' expecting EOF (                  select * from users;                  [select]...)' to match /missing EOF at 'select'/
      at Context.<anonymous> (spec/db.spec.js:771:42)
      at Generator.throw (<anonymous>)
      at step (spec/db.spec.js:31:191)
      at /home/runner/work/sqlectron-core/sqlectron-core/spec/db.spec.js:31:402
      at process._tickCallback (internal/process/next_tick.js:68:7)

  2) db
       cassandra
         given is already connected
           .executeQuery
             INSERT
               should execute multiple queries:
     AssertionError: expected 'line 5:18 mismatched input \'insert\' expecting EOF (...\'user\', \'[email protected]\', \'123456\');                  [insert]...)' to match /missing EOF at 'insert'/
      at Context.<anonymous> (spec/db.spec.js:847:42)
      at Generator.throw (<anonymous>)
      at step (spec/db.spec.js:31:191)
      at /home/runner/work/sqlectron-core/sqlectron-core/spec/db.spec.js:31:402
      at process._tickCallback (internal/process/next_tick.js:68:7)

  3) db
       cassandra
         given is already connected
           .executeQuery
             DELETE
               should execute multiple queries:
     AssertionError: expected 'line 3:18 mismatched input \'delete\' expecting EOF (... where username = \'maxcnunes\';                  [delete]...)' to match /missing EOF at 'delete'/
      at Context.<anonymous> (spec/db.spec.js:919:42)
      at Generator.throw (<anonymous>)
      at step (spec/db.spec.js:31:191)
      at /home/runner/work/sqlectron-core/sqlectron-core/spec/db.spec.js:31:402
      at process._tickCallback (internal/process/next_tick.js:68:7)

  4) db
       cassandra
         given is already connected
           .executeQuery
             UPDATE
               should execute multiple queries:
     AssertionError: expected 'line 3:18 mismatched input \'update\' expecting EOF (... where username = \'maxcnunes\';                  [update]...)' to match /missing EOF at 'update'/
      at Context.<anonymous> (spec/db.spec.js:991:42)
      at Generator.throw (<anonymous>)
      at step (spec/db.spec.js:31:191)
      at /home/runner/work/sqlectron-core/sqlectron-core/spec/db.spec.js:31:402
      at process._tickCallback (internal/process/next_tick.js:68:7)

installation failure

New to Node so I'm sure I'm missing something really basic.
npm install sqlectron-core fails for me.

Using Node 6.8.1 installed via brew on MacOS Sierra 10.12 (16A323)

$ npm --version
3.10.8

$ npm install sqlectron-core
/Users/cswarth
└─┬ [email protected] 
  └── [email protected]  (git+https://github.com/maxcnunes/node-postgres.git#7d31f4f96d5e5ee94260ca0f2aaec9957a53edb6)

npm WARN enoent ENOENT: no such file or directory, open '/Users/cswarth/package.json'
npm WARN cswarth No description
npm WARN cswarth No repository field.
npm WARN cswarth No README data
npm WARN cswarth No license field.

In case the connection is lost it should discard the current connection

If I'm connected to a server. Then I turn off that server. I receive an error message from sqlectron-core that the connection was lost. But seems the connection object still existing and since we never close a connection when leaving a server, if I leave the server and try connecting to the same server again the sqlectron will use the same broken connection :(

@esnunes have you ever seen this problem?

Fetching table columns (and triggers)

Although this is change in GUI too, I think its better to keep this issue here. As mentioned earlier ,now that we have database metadata menu, there should be (at least) list of columns for each table, so that user does not have to do manual query to check existing columns. Furthermore, If there will be auto complete feature, fetching table columns would be required anyways.

If you agree with a idea, I plan on working on this in a week to come, so @maxcnunes you can expect PR on this soon.

Support for Sqlite

Hello, great work,

It's posible to add Support to SQLite data bases

Thanks

Follow operating system config location standards

It would be great if this module followed the XDG Base Directory Specification. Instead of placing the configuration file in the home directory it should be placed in the appropriate directory. Getting the correct directory is easy with a module like env-paths. This, among other things, allows a user to specify a directory in which they want all applications to look for their user configurable setting files and keep their home directory clean.

MySQL bit type

Bit types values in MySQL databases are shown as "{""type"":""Buffer"",""data"":[0]}" or "{""type"":""Buffer"",""data"":[1]}" instead of 0 or 1.
I don't know if this behavior occurs only on MySQL.

Fix failing test for postgresql 12

  2) db
       postgresql
         given is already connected
           .getTableCreateScript
             should return table create script:

      AssertionError: expected 'CREATE TABLE public.users (\n  createdat date NULL,\n  role_id integer NULL,\n  password text NOT NULL,\n  email text NOT NULL,\n  username text NOT NULL,\n  id integer NOT NULL\n);\n\nALTER TABLE public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id)' to deeply equal 'CREATE TABLE public.users (\n  id integer NOT NULL,\n  username text NOT NULL,\n  email text NOT NULL,\n  password text NOT NULL,\n  role_id integer NULL,\n  createdat date NULL\n);\n\nALTER TABLE public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id)'
      + expected - actual

       CREATE TABLE public.users (
      -  createdat date NULL,
      +  id integer NOT NULL,
      +  username text NOT NULL,
      +  email text NOT NULL,
      +  password text NOT NULL,
         role_id integer NULL,
      -  password text NOT NULL,
      -  email text NOT NULL,
      -  username text NOT NULL,
      -  id integer NOT NULL
      +  createdat date NULL
       );
       
       ALTER TABLE public.users ADD CONSTRAINT users_pkey PRIMARY KEY (id)
      
      at Context.<anonymous> (spec/db.spec.js:319:39)
      at Generator.next (<anonymous>)
      at step (spec/db.spec.js:31:191)
      at /home/runner/work/sqlectron-core/sqlectron-core/spec/db.spec.js:31:361
      at process._tickCallback (internal/process/next_tick.js:68:7)

Provide ability to configure the location of the config JSON

At work they blow away our user folder every night so I need to configure the location of the config file. I don't see anything in the docs that suggest this is supported.

I would like to store my config in a location other than \AppData\Local\Sqlectron\Config

Support for SQL Server Schemas other than dbo

The table list comes through just fine only its devoid of schema names so all of the snippets are incorrectly generated. Also there is no way to get a list of Schemas so one would have to know before hand the schema names of the tables in question.

Id be happy to jump in and develop this support if you are willing...

Product Name

Just wanted to make a friendly suggestion. I think the current name isn't as optimal as it could be. I find it's unclear and awkward to pronounce. Is it "sequel-ectron", "s-q-l-ectron"?

Would you consider changing the name to simply...

Selectron

It's

  • Unambiguous
  • Easy to pronounce
  • Rhymes with the key technology you're using without even adding more syllables
  • Rolls off the tongue
  • Plus selectron.io is available... 😉

Just a thought, no disrespect intended 🌹

PostgreSQL SSL Support

Following up on the sqlectron-gui issue to add SSL mode, I found I was still unable to connect to my Heroku psql db.

sqlectron-ssl

Note that error states SSL is off, despite state of "SSL Mode" switch. Digging into the code, I found the problem was with sqlectron-core. While MySQL and SQLServer both adopt ssl settings from server.config, PostgreSQL does not.

I am submitting a pull request with the fix, and while I have built sqlectron-gui and tested that it does in fact work, I did not write specs as there were none for the already implemented mysql and sqlserver ssl support.

Return full command object

Return full command object

My app was relying on executionType attribute from the command object returned by https://github.com/maxcnunes/sql-query-identifier but starting 7.4.0, sqlectron-core is just returning type attribute for all clients. Cause this modification: 770b06c#diff-2f30d89cc6b8682e2400496f14c263e2R265. Why this breaking behavior ?

I try to hack around and reverse the .map((item) => item.type);. Everything works as i expect again except for sqlite client who works a bit differently and return just the type. I would love to have the full object with executionType as well to be consistent with all other clients.

Regards

Deactivate foreign key constraints for SQLServer truncateAllTables

truncateAllTables fails on newer versions of SQLServer (2017+ at least) if there's foreign keys that exist between rows. Similar to MySQL, the foreign key constraints must be disabled when deleting the tables. Unfortunately, SQLServer does not support disabling it at a DB level, rather it's per table, so have to do a sequence of:

  1. Turn off foreign key constraints for all tables
  2. Truncate all tables
  3. Re-index tables
  4. Turn on foreign key constraints for all tables

SQLite fails

This fails:

$ npm install sqlectron-core --save

Output:

node-pre-gyp ERR! Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-linux-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI) (falling back to source compile with node-gyp) 
node-pre-gyp ERR! Tried to download(undefined): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v3.1.13/node-v64-linux-x64.tar.gz 
node-pre-gyp ERR! Pre-built binaries not found for [email protected] and [email protected] (node-v64 ABI) (falling back to source compile with node-gyp) 

....

         ^
Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c:176774:5: note: here
     case JSON_REAL:
     ^~~~
Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c: In function ‘jsonReturn’:
Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c:176891:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
       int_as_real: /* fall through to real */;
       ^~~~~~~~~~~
Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c:176893:5: note: here
     case JSON_REAL: {
     ^~~~
Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c: In function ‘jsonEachColumn’:
Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c:178258:9: warning: this statement may fall through [-Wimplicit-fallthrough=]
       if( p->bRecursive ){
         ^
Release/obj/gen/sqlite-autoconf-3150000/sqlite3.c:178268:5: note: here
     case JEACH_ROOT: {
     ^~~~
  AR(target) Release/obj.target/deps/sqlite3.a
  COPY Release/sqlite3.a
  AR(target) Release/obj.target/deps/sqlite3.a
cp: cannot stat 'Release/obj.target/deps/sqlite3.a': No such file or directory
deps/sqlite3.target.mk:167: recipe for target 'Release/sqlite3.a' failed
make: *** [Release/sqlite3.a] Error 1
make: Leaving directory '/root/node_modules/sqlite3/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/dist/node-v10.15.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.15.0-54-generic
gyp ERR! command "/usr/local/dist/node-v10.15.3-linux-x64/bin/node" "/usr/local/dist/node-v10.15.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/root/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/root/node_modules/sqlite3/lib/binding/node-v64-linux-x64"
gyp ERR! cwd /root/node_modules/sqlite3
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/dist/node-v10.15.3-linux-x64/bin/node /usr/local/dist/node-v10.15.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/root/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/root/node_modules/sqlite3/lib/binding/node-v64-linux-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/root/node_modules/sqlite3/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:970:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
node-pre-gyp ERR! System Linux 4.15.0-54-generic
node-pre-gyp ERR! command "/usr/local/dist/node-v10.15.3-linux-x64/bin/node" "/root/node_modules/sqlite3/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /root/node_modules/sqlite3
node-pre-gyp ERR! node -v v10.15.3
node-pre-gyp ERR! node-pre-gyp -v v0.6.38
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/dist/node-v10.15.3-linux-x64/bin/node /usr/local/dist/node-v10.15.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/root/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node --module_name=node_sqlite3 --module_path=/root/node_modules/sqlite3/lib/binding/node-v64-linux-x64' (1)
  COPY Release/sqlite3.a
  CXX(target) Release/obj.target/node_sqlite3/src/database.o
In file included from ../src/database.cc:4:0:
../src/database.h:10:10: fatal error: nan.h: No such file or directory
 #include <nan.h>
          ^~~~~~~
compilation terminated.
node_sqlite3.target.mk:121: recipe for target 'Release/obj.target/node_sqlite3/src/database.o' failed
make: *** [Release/obj.target/node_sqlite3/src/database.o] Error 1
make: Leaving directory '/root/node_modules/sqlite3/build'
 ERR! build error ....] | install: info lifecycle [email protected]~install: Failed to exec install script
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/dist/node-v10.15.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:189:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12)
gyp ERR! System Linux 4.15.0-54-generic
gyp ERR! command "/usr/local/dist/node-v10.15.3-linux-x64/bin/node" "/usr/local/dist/node-v10.15.3-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/root/node_modules/sqlite3/lib/binding/node-v64-linux-x64/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/root/node_modules/sqlite3/lib/binding/node-v64-linux-x64"
gyp ERR! cwd /root/node_modules/sqlite3
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN enoent ENOENT: no such file or directory, open '/root/package.json'
npm WARN root No description
npm WARN root No repository field.
npm WARN root No README data
npm WARN root No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-08-20T09_15_52_970Z-debug.log

Note: I did run this as root as other means of installing also failed.

Use typescript

Since this library supports different database types and all of them need to follow the same interface contract it would be simpler to ensure those contracts are being respected if it was written in typescript.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.