kostafey / ejc-sql Goto Github PK
View Code? Open in Web Editor NEWEmacs SQL client uses Clojure JDBC.
Emacs SQL client uses Clojure JDBC.
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")
[M-x ejc-connect RET PostgreSQL RET]
to launch a new ejc-sql REPL session. ,#+begin_src sql :eval no
SELECT * from test;
,#+end_src
[C-c C-c]
on SQL statement line to eval. But it shows warning: Run M-x ejc-connect first!
.Use full connection uri as in Clojure jdbc :connection-uri
.
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)
Autocompletion optional fuzzy matching.
What is the sql-ansi-mode? Why I can't find it? While sql-mode works fine?
(void-variable clomacs--doc)
(void-variable clojure\.repl/doc)
This is the error output of:
(use-package elj-sql
:ensure t)
Autocompletion for columns of views.
Terminate running queries.
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
,
sqlite
~/.m2/
.Persist database structure cache between connection sessions.
Restrict the number of records to show by Statement, add [fetch more].
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
invalid character (ORA-00911) for ejc-show-tables-list
Handle queries with / chars in strings.
Java process persists for H2 database server after nREPL process terminated.
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
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()
....
Handle case:
/
-- http://localhost:8080
select * from table
/
Better SQL strip regex.
Show current connection name for SQL buffer.
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))
because auto-complete
's ac-sources
iterate over all ac-source list functions.
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.
Try to use OpenJPA SQLFormatter or Hibernate one.
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 :)
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
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
Update & insert related autocompletion.
Handle Blob results.
Fix SQL dialect.
CIDER launch for project is async by default. ejc-connect
takes about 1.5 minutes, it is not very long, but if async is easy, I hope it can be async.
Check if the database has at least one table - #38 (comment)
Sometimes I have to restart emacs multiple times. Is there a way to keep the ejc-sql clojure backend alive between emacs restarts or run the backend out of emacs and connect to it from emacs, like cider-connect
It will save a lot of time. Also the backend is very stable and I don't have a need to restart it everytime with emacs.
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
Current keybindings are short and will probably clash with some pre-existing ones (most notably, C-c p
is used by projectile). This can be resolved on case-by-case basis, but it's probably worth it to provide a configurable keymap prefix. Here's how projectile does it: https://github.com/bbatsov/projectile/blob/da581cdfe4f4f63137f3320ed3dbda9cf6c20e14/projectile.el#L3469-L3523
Add database structure visualisation tree via direx
.
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.
Autocomplete inside brackets
select max(t.#) from table t
Add ElDoc for stored procedures & queries.
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 for stored procedures.
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
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.
Add JDBC driver to CLASSPATH for new connections if new connection refers to the different database type.
OPTIONALLY: Remove JDBC from CLASSPATH when buffer with last connection requires this type of JDBC is closed.
Keep connection usage statistics and offer most frequently used first when ejc-connect
is called.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.