allegro cl, mysql, clsql

Discussion of Common Lisp

allegro cl, mysql, clsql

Postby amrita » Sun Jan 29, 2012 4:48 am

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?
amrita
 
Posts: 2
Joined: Sat Jan 28, 2012 4:44 am

Re: allegro cl, mysql, clsql

Postby wvxvw » Wed Feb 01, 2012 7:44 am

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.
wvxvw
 
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am

Re: allegro cl, mysql, clsql

Postby amrita » Wed Feb 01, 2012 7:54 am

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.
amrita
 
Posts: 2
Joined: Sat Jan 28, 2012 4:44 am

Re: allegro cl, mysql, clsql

Postby wvxvw » Fri Feb 03, 2012 12:53 pm

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.
wvxvw
 
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am


Return to Common Lisp

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests

cron