GithubHelp home page GithubHelp logo

kostafey / ejc-sql Goto Github PK

View Code? Open in Web Editor NEW
277.0 10.0 29.0 870 KB

Emacs SQL client uses Clojure JDBC.

Emacs Lisp 50.95% Clojure 48.17% Makefile 0.21% YASnippet 0.68%
emacs sql jdbc clojure clomacs

ejc-sql's Issues

[C-c C-c] can't evaluate SQL statement

Here is my steps to reproduce this issue:

(ejc-create-connection
   "PostgreSQL"
   :classpath "~/.m2/repository/postgresql/postgresql/9.3-1102.jdbc41/postgresql-9.3-1102.jdbc41.jar"
   :dbtype "postgresql"
   :host "localhost"
   :port "5432"
   :user "postgres"
   :password "***"
   :dbname "postgres")
  1. [M-x ejc-connect RET PostgreSQL RET] to launch a new ejc-sql REPL session.
  2. In another Org Mode file buffer, open a sql source block like this:
   ,#+begin_src sql :eval no
   SELECT * from test;
   ,#+end_src
  1. In the opened source block dedicated buffer, I press [C-c C-c] on SQL statement line to eval. But it shows warning: Run M-x ejc-connect first!.

ejc-sql auto-complete error

Here is my configuration:

(use-package ejc-sql
  :ensure t
  :commands (ejc-connect ejc-connect-existing-repl ejc-sql-mode)
  :config
  (defun my-ejc-sql-ac-setup ()
    (ejc-sql-mode 1)
    (auto-complete-mode 1)
    (ejc-ac-setup))
  (add-hook 'sql-mode-hook #'my-ejc-sql-ac-setup)

  ;; (advice-add 'ejc-connect :before
  ;;             #'(lambda (connection-name)
  ;;                 (switch-to-buffer-other-window (format "*ejc-sql %s*" connection-name))))
  
  (ejc-create-connection
   "PostgreSQL-db-postgres"
   :classpath "~/.m2/repository/postgresql/postgresql/9.3-1102.jdbc41/postgresql-9.3-1102.jdbc41.jar"
   :dbtype "postgresql"
   :host "localhost"
   :port "5432"
   :user "postgres"
   :password "324324"
   :dbname "postgres")

  (ejc-create-connection
   "MariaDB-db-test"
   :classpath "~/.m2/repository/org/mariadb/jdbc/mariadb-java-client/1.1.7/mariadb-java-client-1.1.7.jar"
   :dbtype "mysql"
   :host "localhost"
   :port "3306"
   :user "root"
   :password "324324"
   :dbname "test")
  
  (ejc-create-connection
   "MySQL-db-test"
   :classpath "~/.m2/repository/mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32.jar"
   :dbtype "mysql"
   :host "localhost"
   :port "3306"
   :user "root"
   :password "324324"
   :dbname "test")
  )

After ejc-connect, I input sel I got error in auto-complete:

Error running timer ‘ac-update-greedy’: (error "MySQLSyntaxErrorException Unknown column ’s.schema_owner’ in ’field list’  sun.reflect.NativeConstructorAccessorImpl.newInstance0 (NativeConstructorAccessorImpl.java:-2)

MELPA install issue

(void-variable clomacs--doc)
(void-variable clojure\.repl/doc)

This is the error output of:

(use-package elj-sql
  :ensure t)

Add helper functions to interactively setup SQL connection

Hope ejc-sql can create a universal helper function to help user setup SQL connection interactively.

For example, a command ejc-sql-connect-to-sql,

  1. it will show the stored connections in persistent when no input yet.
  2. After user input some characters like sqlite
  3. if has match connection, then select it to connect.
  4. if has no match connection, then create a new connect with the inputted string.
  5. then interactively prompt user to input parameters of the connection, even auto show the available SQL JDBC drivers in available possible paths like ~/.m2/.

Cannot install in spacemacs

I tried installing it in spacemacs by running M-x package-install RET ejc-sql. I got a compilation error ejc-sql.el:41:1:Error: Symbol's value as variable is void: clomacs--doc and the package fails to install

Alias for table (MSSQL) doesn't show columns

Hi,

I've got ejc-sql installed into Emacs 25.3.1 with Spacemacs on Windows 10.
I've installed JDBC driver (version 6.2, the latest one) as explained in the documentation.
I'am able to connect to the database, do queries etc.

But when I try such code:

select
  *
from
  dbo.Entity as e
where
  e.

I don't get autocomplete on the last line. If I put there proper value and execute - everything works.

Please advise.

PS: if you need more information please let me know and I'll provide it.

Best regards,
Kirill

ejc-connect-existing-repl error

Debugger entered--Lisp error: (wrong-type-argument listp 46165)
  call-interactively(ejc-connect-existing-repl record nil)
  command-execute(ejc-connect-existing-repl record)
  #f(compiled-function (cmd) #<bytecode 0x28c4071>)("ejc-connect-existing-repl")
  ivy-call()
....

use an option to control input uppercase candidates or not

Here is the implementation, if you want, I can send PR:

(defcustom ejc-candidates-uppercase t
  "Use uppercase candidates or downcase.
Uppercase by default, set to nil to use downcase candidates."
  :type 'boolean
  :safe #'booleanp
  :group 'ejc-sql)

(defun ejc-get-ansi-sql-words ()
  (if (not (or (ejc-return-point) (ejc-get-prefix-word)))
      (progn
        (if ejc-candidates-uppercase
            (append (mapcar 'upcase ejc-ansi-sql-words)
                    (mapcar 'upcase ejc-auxulary-sql-words))
          (append ejc-ansi-sql-words
                  ejc-auxulary-sql-words)))
    nil))

Feel suspend when input first character for completion

because auto-complete's ac-sources iterate over all ac-source list functions.

  • ejc-columns-candidates
    • ejc-get-prefix-word
  • ejc-tables-candidates
  • ejc-owers-candidates
  • ejc-get-ansi-sql-words

I noticed ejc-get-prefix-word function is invoked everytime ac-source function like ejc-columns-candidates called with macro ejc-candidates. Why not cache it to speed up? Because ejc-get-prefix-word function is implemented with regexp backward search, also use mark save-excursion etc. I can feel the obviousely suspend when input character.

C-c e t seems to include tables only from dbo schema for MS Sql Server

Hi,

When I do C-c e t the returned list of tables in the database has only tables from dbo schema.
I'm using Sql Server 2016.
I can track it till (def default-queries ..) where :tables gets set, and it is used later for ms sql, and the schema there is dbo in my case (checked with profiler) which filters out everything other than dbo, but can't figure out further :)

[[Bug]] `\` Char Doesn't Have Any Effect

I've noticed this for a while but I recently downloaded the most recent update (20180827.1408) and I've still noticed it.

Putting a \ after a query pretty much does nothing with the entire buffer being highlighted on C-c C-c and, naturally, a response of "Error: Incorrect syntax near ''."

The version of Emacs I'm currently running is

GNU Emacs 26.1 (build 1, x86_64-apple-darwin17.5.0, Carbon Version 158 AppKit 1561.4) of 2018-06-06

ejc-open-log couldn't find log path

When i run ejc-open-log, it doesn't take me to the log file.
In the Messages window I see these messages

Searching for ejc-get-log-file-path...
find-file--read-only: ejc-sql/2016-09-15.log does not exist

I guess we should change to use absolute paths in this function

No implementation of method: :as-file of protocol: #’clojure.java.io/Coercions found for class: java.lang.Boolean clojure.core/-cache-protocol-fn

When trying to connect to a database with "ejc-connect" I get

Starting nREPL server for ejc-sql...
[nREPL] server started on 45811
[nREPL] Establishing direct connection to localhost:45811 ...
[nREPL] Direct connection to localhost:45811 established
Started.
clomacs-get-result: IllegalArgumentException No implementation of method: :as-file of protocol: #’clojure.java.io/Coercions found for class: java.lang.Boolean clojure.core/-cache-protocol-fn (core_deftype.clj:583)

I use debian testing linux x64
lein -v
Leiningen 2.8.1 on Java 1.8.0_171 OpenJDK 64-Bit Server VM

regards
Matteo

Enhance README

I don't know how to set ejc-sql for SQLite, PostgreSQL and MySQL.
Can you show examples in README. And add those examples in README? So that some newbie can setup by following those examples.
Thanks in advance.

ac-update-greedy schema_owner

I keep getting this error. It does not stop the query from working but it does interfere with the autocomplete.

Error running timer ‘ac-update-greedy’: (error "SQLSyntaxErrorException Unknown column ’schema_owner’ in ’field list’ com.mysql.cj.jdbc.exceptions.SQLError.createSQLException (SQLError.java:536)")

autocomplete doesnt' work due to time out

I am connecting to a remote sql server.
I couldn't get auto complete to work. I see this in the message buffer

Receiving database structure... [2 times]
Error running timer `ac-show-menu': (error "Sync nREPL request timed out (op eval session 4fda92d6-379d-4348-af0d-f7a59ad7b6e3 code (require 'ejc-sql.connect) (ejc-sql.connect/eval-sql-internal-get-column {:classname \"oracle.jdbc.OracleDriver\" :subprotocol \"oracle\" :subname \"thin:@//xxx.com\" :user \"xxx\" :password \"xxx\"} \"select DISTINCT(owner)  from ALL_OBJECTS\") id 36)")
Error running timer `ac-update-greedy': (error "Sync nREPL request timed out (op eval session 4fda92d6-379d-4348-af0d-f7a59ad7b6e3 code (require 'ejc-sql.connect) (ejc-sql.connect/eval-sql-internal-get-column {:classname \"oracle.jdbc.OracleDriver\" :subprotocol \"oracle\" :subname \"thin:@//xxx.com\" :user \"xxx\" :password \"xxx\"} \"select DISTINCT(owner)  from ALL_OBJECTS\") id 35)")

can we increase the timout time and make it configurable

don't call (sql-mode) to invalid Org Babel source block [C-c '] to exit

ejc-configure-sql-buffer will execute (sql-mode). change Babel source block `major-mode'. Then when I press [C-c '] to exist sql source block will be invalid.

add a if condition to detect whether current buffer is in source block editing dedicate buffer. Because SQL source block is sql-mode already, so no need to invoke sql-mode again.

(defun ejc-configure-sql-buffer (product-name)
  (unless (org-src-edit-buffer-p)
    (sql-mode))
  (sql-set-product (or (cdr (assoc-string product-name ejc-product-assoc))
                       (car (assoc-string product-name sql-product-alist))
                       "ansi"))
  (auto-complete-mode t)
  (auto-fill-mode t)
  (ejc-sql-mode)
  (ejc-sql-mode t))

If you accept this patch, I will add an PR.

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.