luasql.mysql.dll_Error: bad argument #1 to 'insert' (table expected, got nil)

2014-07-04 06:15:16

0

I am trying to connect to a mysql server using LuaSql via a mysql proxy. I try to execute a simple program (db.lua):

require("luasql.mysql")

local _sqlEnv = assert(luasql.mysql())

local _con = nil

function read_auth(auth)

local host, port = string.match(proxy.backends[1].address, "(.*):(.*)")

_con = assert(_sqlEnv:connect( "db_name", "username", "password", "hostname", "3306"))

end

function disconnect_client()

assert(_con:close())

end

function read_query(packet)

local cur = con:execute("select * from t1")

myTable = {}

row = cur:fetch(myTable, "a")

print(myTable.id,myTable.user)

end

This code executes well when I execute it without mysql-proxy. When I am connecting with mysql-proxy, the error-log displays these errors:

mysql.lua:8: bad argument #1 to 'insert' (table expected, got nil)

db.lua:1: loop or previous error loading module 'luasql.mysql'

mysql.lua is a default file of LuaSql:

---------------------------------------------------------------------

-- MySQL specific tests and configurations.

-- $Id: mysql.lua,v 1.4 2006/01/25 20:28:30 tomas Exp $

---------------------------------------------------------------------

QUERYING_STRING_TYPE_NAME = "binary(65535)"

table.insert (CUR_METHODS, "numrows")

table.insert (EXTENSIONS, numrows)

---------------------------------------------------------------------

-- Build SQL command to create the test table.

---------------------------------------------------------------------

local _define_table = define_table

function define_table (n)

return _define_table(n) .. " TYPE = InnoDB;"

end

---------------------------------------------------------------------

-- MySQL versions 4.0.x do not implement rollback.

---------------------------------------------------------------------

local _rollback = rollback

function rollback ()

if luasql._MYSQLVERSION and string.sub(luasql._MYSQLVERSION, 1, 3) == "4.0" then

io.write("skipping rollback test (mysql version 4.0.x)")

return

else

_rollback ()

end

end

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值