Page 1 of 1

allegro cl, mysql, clsql

Posted: Sun Jan 29, 2012 4:48 am
by amrita
I connected my database 'puzzle_maker' with allegro cl using clsql.

* (clsql:connected-databases)

(#<CLSQL-MYSQL:MYSQL-DATABASE /puzzle_maker/root OPEN @ #x217f159a>)

But when I use the query command it is giving me an error message:

* (clsql-sys:query "select * from category_table")

Error: Attempt to call #<Vector @ #x211265ea> for which the definition has not yet been
(or is no longer) loaded.
[condition type: SIMPLE-ERROR]

Does anyone know what I am doing wrong?

Re: allegro cl, mysql, clsql

Posted: Wed Feb 01, 2012 7:44 am
by wvxvw
This is a pure guess, but I would be looking for a macro, something like (with-connection ...) to do what you need. It might be that the command you used closes the connection right away after you opened it. Does that make sense?

BTW, if the IDs you posted are taken from the same session, then it looks like you issued a select query before the connection had been established - so this must be caused by async call to MySQL server or something of that kind. So, if it is async, then you'd need to see the docs on a way to design a connection handler (sink, reader, or whichever they used to call it) to make sure that the select is called only after the connection is established.

Re: allegro cl, mysql, clsql

Posted: Wed Feb 01, 2012 7:54 am
by amrita
I'm sorry, I'm very new to Lisp. wvxvw, could you please explain further what you meant in the first paragraph?

And the IDs are taken from the same session, but I was definitely connected to the database before the select query.

Re: allegro cl, mysql, clsql

Posted: Fri Feb 03, 2012 12:53 pm
by wvxvw
I really used this library only once, and it was almost a year ago, so I'm not certain, however, this worked as per what I can remember: http://clsql.b9.com/manual/with-database.html . What this means is that when you do connect-databases, it creates a connections pool, but before you can run a select query, you need to tell clsql what database are you targeting (there may be multiple open connections at the same time). This macro seem to be doing exactly that. I.e. once you select some database, you would query that database inside the macro.