|
Hi David On 2015-10-13 08:44, David Muscut wrote:
Are you sure this is possible? Note that LuaSQL's MySQL driver is just a bind to the C API. When you try to connect to the database, you are calling mysql_real_connect with the same parameters provided to Lua and some default: the unix_socket will be always NULL and the client_flag will be always 0. The driver also does not provide any support for using mysql_options.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?
It seems that the --protocol=tcp is important when using mysql client, but I am not sure if this affects LuaSQL usage.The following works: $ mysql -P9306 --protocol=tcp --prompt='sphinxQL> '
As Phillip Janda already mentioned, you are using the connect method incorrectly, unless your database is called 'localhost' and your user is called '9306' :-) You have to provide the strings for each argument or nil:The following does not: $ lua5.1 Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Riomysql = 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)
connection = env:connect("database-name", "username", "password", nil, 9306)
Have you tried something like that? Regards, Tomás