mysql - Luasql error: "LuaSQL: error connecting to database" -


i working on mysql. trying acess mysql database using luasql.i have installed luasql using yum. tried following code:

mysql = require "luasql.mysql"  env = assert(mysql.mysql())  con = assert(env:connect ( "db_name", "username", "password", "localhost"))  no, name in rows (con, "select * t1")  print (string.format ("%s", name))  end 

while executing above code getting following error :

lua: check.lua:3: luasql: error connecting database. mysql: can't connect local mysql server through socket '/var/run/mysqld/mysqld.sock' (2) stack traceback:     [c]: in function 'assert'     check.lua:3: in main chunk     [c]: ? 

how overcome error.can me proper execution of code? !!!

the variables in env:connect should variables such below

local db_conn = env:connect("test_db", "root", "abc123", "192.168.1.3", 3306) local cur = db_conn:execute("select * t1") local row = cur:fetch({}, 'a') k, v in pairs(row)     print(k, v) end 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -