SQL Integration

92 views
Skip to first unread message

Lizelle Matthews

unread,
Oct 17, 2013, 6:34:46 AM10/17/13
to tin...@googlegroups.com
Hey all,

I'm relatively new to the world of MU* coding, and was given a project because I had a decent knowledge of SQL. When attempting to get this working on TinyMux 2.10, I manage to get the modules compiled and loaded, and Stubslave seems to be working fine according to the log, but no matter which query I attempt to run, I get the below response. I've tested the connection to the database, the username, password and everything, and they're all correct.

Object:
FOO.TR: @if rserror()={@pemit %#=Rows: [rsrows()];@if rsrows()={@trig me/bar.tr}},{@pemit %#=Error: [rserror()]}
BAR.TR: @pemit %#=rsrec(|);@if rsnext()={@trig me/bar.tr}

Command:
@query/sql SQL/foo.tr=/show tables

Output:
Triggered.
Error: #-2 NO SESSION

Again the disclaimer: I am somewhat of a n00b at this, so I'd appreciate any and all assistance.

Thanks
Lizelle

Stephen Dennis

unread,
Oct 17, 2013, 9:38:09 AM10/17/13
to tinymux
#-2 NO SESSION happens for two reasons.

1) At compile-time, it wasn't able to find MySQL. Look at autoconf.h in src/modules. If you see something like the following, you need to install the mysqlclient.

/* Define if mysql exists. */
/* #undef HAVE_MYSQL */

2) mysql_init(NULL) returned NULL which can only happen in the very unlikely case there is insufficient memory.


So, yeah, it is probably the lack of the mysqlclient package. You may be running MySQL server and yet not have the client, or you may be running MySQL on a different machine, but you lack any MySQL pieces on the machine the game is running on.


Brazil



--
 
---
You received this message because you are subscribed to the Google Groups "tinymux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tinymux+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lizelle Matthews

unread,
Oct 17, 2013, 12:56:49 PM10/17/13
to tin...@googlegroups.com
Hi Brazil,

Thanks for the speedy answer. I had a look in the file, with the following SQL defines:

/* Define to 1 if you have the 'mysqlclient' library (-lmysqlclient). */
#define HAVE_LIBMYSQLCLIENT 1

/* Define if mysql exists. */
#define HAVE_MYSQL

/* Define if mysql.h exists. */
#define HAVE_MYSQL_H

IIRC, I ran the compile with ./Compile --enable-stubslave --with-mysql-include=/usr/include/mysql --with-mysql-libs=/usr/lib/mysql --enable-realitylvls. The only place where it varied from the method you listed at https://groups.google.com/forum/#!searchin/tinymux/hspace/tinymux/IPKg0cTwdxQ/5kDnsvs9wi8J was that under Modules, I had to run a 'make depend'. 

Memory trouble then?

Thanks
Lizelle

Stephen Dennis

unread,
Oct 17, 2013, 1:03:34 PM10/17/13
to tinymux
Verify you are using the latest TinyMUX 2.10. I don't have the code up in front of me, but the previous version of this part of the code would connect successfully when the game started/@restarted, but then lose the connection after say 30 minutes of being idle. There are MySQL session options to 'prevent' this, but I've never been able to get them to work reliably. The new version of the code remembers your credentials and will reestablish the lost connection.

In short, a third case was possible in earlier versions: 3) connection to MySQL idled out.

Brazil

Lizelle Matthews

unread,
Oct 22, 2013, 3:14:59 PM10/22/13
to tin...@googlegroups.com
Hi all,

Finally got this working.

1) First of all, do as Brazil says and make sure you're on mux2.10. Our game turned out to be on 2.9.something.
2) Make sure that SQL is open from the commandline: mysql -h <host name> -u <username> -p<password> -D <database name>. It will pretty much tell you if there's a fault. In our case, we had to get the host to do a flush because the IP had been blacklisted erroneously.
3) To test in-game, make an object as described in the SQL helpfile that comes with the game. 
4) Enjoy.

Thank you very much to Brazil and the others that assisted me with this, I really appreciated it.
Lizelle
Reply all
Reply to author
Forward
0 new messages