SBCL & MySQL (clsql, cffi)
SBCL & MySQL (clsql, cffi)
Hello!
I want to interconnect sbcl and mysql. I have installed required packets with clbuild.
Then I do:
(require :asdf)
(asdf:operate 'asdf:load-op 'clsql)
(use-package :clsql-user)
(connect `("host" "dbname" "root" "password") :database-type :mysql)
And it says me:
debugger invoked on a TYPE-ERROR in thread #<THREAD "initial thread" RUNNING
{1002DA3EA1}>:
The value
(BABEL:STRING-SIZE-IN-OCTETS "SET SESSION sql_mode='ANSI'" :ENCODING
(OR NIL CFFI:*DEFAULT-FOREIGN-ENCODING*))
is not of type
(UNSIGNED-BYTE 32).
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
((FLET #:G386) #.(SB-SYS:INT-SAP #X00641B80))
0] 0
I have tried to do:
* (setf cffi:*default-foreign-encoding* :cp1251)
:CP1251
I have set different encoding values: utf8,cp1251,ansi - it doesn't matter and I have the same result.
Actually the question: how to fight with this? What it want to say to me and how to do it right way?
Thank you!
p.s. I have installed required packets with clbuild - all packets are last stable versions from repos. I have tried it on Fedora and Ubuntu. I have fail to install packets with ASDF but I have installed them with clbuild OK. The result is the same with both OS's.
I want to interconnect sbcl and mysql. I have installed required packets with clbuild.
Then I do:
(require :asdf)
(asdf:operate 'asdf:load-op 'clsql)
(use-package :clsql-user)
(connect `("host" "dbname" "root" "password") :database-type :mysql)
And it says me:
debugger invoked on a TYPE-ERROR in thread #<THREAD "initial thread" RUNNING
{1002DA3EA1}>:
The value
(BABEL:STRING-SIZE-IN-OCTETS "SET SESSION sql_mode='ANSI'" :ENCODING
(OR NIL CFFI:*DEFAULT-FOREIGN-ENCODING*))
is not of type
(UNSIGNED-BYTE 32).
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
((FLET #:G386) #.(SB-SYS:INT-SAP #X00641B80))
0] 0
I have tried to do:
* (setf cffi:*default-foreign-encoding* :cp1251)
:CP1251
I have set different encoding values: utf8,cp1251,ansi - it doesn't matter and I have the same result.
Actually the question: how to fight with this? What it want to say to me and how to do it right way?
Thank you!
p.s. I have installed required packets with clbuild - all packets are last stable versions from repos. I have tried it on Fedora and Ubuntu. I have fail to install packets with ASDF but I have installed them with clbuild OK. The result is the same with both OS's.
“To avoid criticism do nothing, say nothing, be nothing.â€- Elbert Hubbard
personal blog - developer in Ukraine
personal blog - developer in Ukraine
Re: SBCL & MySQL (clsql, cffi)
I have not experience with clsql, but don't you have to load a clsql-mysql backend specific system explicitly?
Also, I think the best way to install systems right now is quicklisp, despite being still marked as beta.
Also, I think the best way to install systems right now is quicklisp, despite being still marked as beta.
Re: SBCL & MySQL (clsql, cffi)
I think load cl-sql is just enough. Because when I set incorrect login/password pair it says: "Access denied for user 'root'@'localhost' (using password: YES)". So I think clsql works properly and it tires to connect to mysql. Maybe this is problem with babel or something else. I don't know.Ramarren wrote:I have not experience with clsql, but don't you have to load a clsql-mysql backend specific system explicitly?
As I understood this is just a packer manager? Something like clbuild or ASDF?Also, I think the best way to install systems right now is quicklisp, despite being still marked as beta.
“To avoid criticism do nothing, say nothing, be nothing.â€- Elbert Hubbard
personal blog - developer in Ukraine
personal blog - developer in Ukraine
Re: SBCL & MySQL (clsql, cffi)
Clbuild and ASDF have different purpose, and in fact clbuild uses asdf. ASDF is a system definition facility, a sort of equivalent to make, which is responsible for compiling and loading files that compose a system. CLbuild is a script used to download those files from repositories. But it doesn't really qualify as a "manager", since it doesn't really manage anything. Quicklisp stores its own copies of systems, and they are much more likely to be in version which work together. It also uses ASDF to load systems, although it creates a hook that automatically downloads missing dependencies.erazer wrote:As I understood this is just a packer manager? Something like clbuild or ASDF?
Re: SBCL & MySQL (clsql, cffi)
Thank you.
I just tried to use quicklisp now.
So...
I have deinstalled BSCL at all and install it again.
Then I use quicklisp to install cl-mysql
Then I try to connect to mysql server:
(cl-mysql:connect "127.0.0.1" "dbname" "root" "password")
And what it says to me:
debugger invoked on a SB-INT:SIMPLE-PROGRAM-ERROR in thread #<THREAD
"initial thread" RUNNING
{1002DA3E41}>:
unknown &KEY argument: "127.0.0.1"
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(COM.HACKINGHAT.CL-MYSQL-SYSTEM:CONNECT)[:EXTERNAL]
0] 0
What am I doing wrong now? How to use connect function properly? Help me, please
I just tried to use quicklisp now.
So...
I have deinstalled BSCL at all and install it again.
Then I use quicklisp to install cl-mysql
Then I try to connect to mysql server:
(cl-mysql:connect "127.0.0.1" "dbname" "root" "password")
And what it says to me:
debugger invoked on a SB-INT:SIMPLE-PROGRAM-ERROR in thread #<THREAD
"initial thread" RUNNING
{1002DA3E41}>:
unknown &KEY argument: "127.0.0.1"
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(COM.HACKINGHAT.CL-MYSQL-SYSTEM:CONNECT)[:EXTERNAL]
0] 0
What am I doing wrong now? How to use connect function properly? Help me, please
“To avoid criticism do nothing, say nothing, be nothing.â€- Elbert Hubbard
personal blog - developer in Ukraine
personal blog - developer in Ukraine
Re: SBCL & MySQL (clsql, cffi)
I did it...
(cl-mysql:connect :host "localhost" :database "dbname" :user "root" :password "password")
(cl-mysql:query "select * from status limit 10" :store nil)
But how to get the result?...
(cl-mysql:connect :host "localhost" :database "dbname" :user "root" :password "password")
(cl-mysql:query "select * from status limit 10" :store nil)
But how to get the result?...
“To avoid criticism do nothing, say nothing, be nothing.â€- Elbert Hubbard
personal blog - developer in Ukraine
personal blog - developer in Ukraine
Re: SBCL & MySQL (clsql, cffi)
The clsql-mysql system is a backend. Your load the backed appropriate to the database you want to use, although from what I can see clsql tries to load a proper system automatically, but you interact directly with the frontend, which is the main clsql system. That is, the clsql:connect with MySQL specific connection specification. And generally. I don't think using the backend directly is recommended. Best read the manual.
Re: SBCL & MySQL (clsql, cffi)
CL-USER> (clsql:connect '("localhost" "mysql" "root" "password") :database-type :mysql :if-exists :old)
#<MYSQL-DATABASE localhost/mysql/root OPEN #x1884FB06>
CL-USER> (let ((query "select * from db "))
(clsql:do-query ((&rest field-vals) query)
(prin1 field-vals)))
("%" "test" "" "Y" "Y" "Y" "Y" "Y" "Y" "N" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "N" "N")("%" "test\\_%" "" "Y" "Y" "Y" "Y" "Y" "Y" "N" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "N" "N")
#<MYSQL-DATABASE localhost/mysql/root OPEN #x1884FB06>
CL-USER> (let ((query "select * from db "))
(clsql:do-query ((&rest field-vals) query)
(prin1 field-vals)))
("%" "test" "" "Y" "Y" "Y" "Y" "Y" "Y" "N" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "N" "N")("%" "test\\_%" "" "Y" "Y" "Y" "Y" "Y" "Y" "N" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "Y" "N" "N")
Re: SBCL & MySQL (clsql, cffi)
thank you
but this is for clsql
as I have fail with clsql connection (see firs message) I have installed cl-mysql (from http://www.hackinghat.com/index.php/cl-mysql) and now trying to get it work.
I can connect to DB via cl-mysql
(cl-mysql:connect :host "localhost" :database "dbname" :user "root" :password "password")
...and do a query
(cl-mysql:query "select * from status limit 10" :store nil)
But I don't understand how to get the result from the query. I think clsql and cl-mysql are just different in this way.
May be you can help me?
Thank you.
but this is for clsql
as I have fail with clsql connection (see firs message) I have installed cl-mysql (from http://www.hackinghat.com/index.php/cl-mysql) and now trying to get it work.
I can connect to DB via cl-mysql
(cl-mysql:connect :host "localhost" :database "dbname" :user "root" :password "password")
...and do a query
(cl-mysql:query "select * from status limit 10" :store nil)
But I don't understand how to get the result from the query. I think clsql and cl-mysql are just different in this way.
May be you can help me?
Thank you.
“To avoid criticism do nothing, say nothing, be nothing.â€- Elbert Hubbard
personal blog - developer in Ukraine
personal blog - developer in Ukraine
Re: SBCL & MySQL (clsql, cffi)
Sorry, I misread, because I wasn't really aware cl-mysql existed. I don't have MySQL even installed on my system, so I cannot test it.erazer wrote:but this is for clsql
The documentation on the very page you linked appears reasonably clear. What is it that you don't understand about it?erazer wrote:But I don't understand how to get the result from the query.