lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Am 13.10.2015 um 13:44 schröbte David Muscut:
I want to script a query to a SphinxQL server (via the MySQL 4.1 transport
protocol). I can query the server properly via the command line mysql
client, but am unable to via luasql. Can someone point me to a working
example of how to use luasql to query a sphinxql server?

The following works:
$ mysql -P9306 --protocol=tcp --prompt='sphinxQL> '

The following does not:
$ lua5.1
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
mysql = require "luasql.mysql"
env  = mysql.mysql()
= env:connect('localhost','9306')
nil    LuaSQL: error connecting to database. MySQL: Access denied for user
'9306'@'localhost' (using password: NO)
return  env:connect('user','pass','localhost','9306')
nil    LuaSQL: error connecting to database. MySQL: Can't connect to MySQL
server on '9306' (22)

The luasql documentation[1] says that the first argument (after `self`) has to be the `sourcename` (I think that's the database name):

    env:connect(sourcename[,username[,password[,hostname[,port]]]])


thanks!
-D


Philipp

[1]: http://keplerproject.github.io/luasql/doc/us/manual.html#mysql_extensions