This module is really a tool for script developers who want to access a MySQL database without an extra Tcl module. This module may be required by certain scripts. For an example script, see MySeen in the scripts section of this site.



  1. Obtain this package.
  2. Place it in ~/eggdrop1.6.x/src/mod/
  3. Decompress it: tar jxvf mysqlx.x.tar.bz2
  4. Go back to your ~/eggdrop1.6.x directory
  5. ./configure (if needed)
  6. make config
  7. make
  8. make install
  9. Edit you bot's *.conf file and add the line: loadmodule mysql
  10. Rehash your bot

Tcl Commands

mysql_connect <database> <hostname> [user] [password] [socket|port]
Initializes the connection to the database. If hostname is `localhost', the connection will be piped into a socket instead of using a tcp port. Socket is the path to the unix socket, such as /tmp/mysql.sock.
Closed the current database connection, freeing its memory.
mysql_query <query>
Executes a query and returns its results in a nested list. A semi-colon is automatically appended to the end of the statement.
mysql_escape [bytes] <string>
Makes a string safe to be used in MySQL. Adds backslashes before single quotes, doubles backslashes, and so on. Only specify the bytes argument if you are handling binary data. Using it incorrectly will crash your bot, or worse.
Returns the error code that was last encountered. A list of error codes is available at
Checks whether the connection to the server is working. If it has gone down, an automatic reconnection is attempted.
If connected, returns a list of database name, hostname, user, and port/sock.
Returns the ID from the last insertion.
Return whether the module thinks the database is linked (true) or not (false).
This is a client-side command, so it does not verify that the underlying (TCP) connection is still alive
Returns the number of rows that were changed by the last query.

Scripts for MySQL.mod

This is a fully-functional sample script for the module, by BarkerJr
myacro is an acro game script with support for the MySQL module, by rojo

To Do List

  • Add mysql_pconnect as an alias for mysql_connect, so as to ease conversion from PHP.
  • Remove the "mysql/" prefix in mysql_mod.h, since the mysql_config should point directly to the file, not the directory above.
  • Add inter-module C-functions so that other modules can call this one.
  • Support multiple database connections.
  • Allow null database name (queries will need to be prefixed with dbname)