zuec / lua-mysql-1

MySQL 5.5 access for Lua 5.3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lua-mysql

lua-mysql is a simple(but not complete) Lua 5.3 binding of MySQL 5.5 C API

Installation

First obtain premake5, then a C99 compiler and libmysqlclient library is needed.

Build on Windows 7 x64

  1. Type premake5 vs2013 on command window to generate Visual C++ solution files.
  2. Use Visual Studio 2013(either Ultimate or Community version) to compile executable binary.
  3. Pre-compiled Windows x86/64 libmysql binary can be obtained here

Build on Ubuntu 14.04 64-bit

  1. Type sudo apt-get install libmysqlclient-dev
  2. Type premake5 gmake && make config=release

Usage at a glance

local mysql = require 'luamysql'
local client = mysql.new_client()
client:connect{host = 'localhost', user = 'root', passwd = 'mypwd', db = 'test'}
local cur = client:execute('select * from test')
while true do
     local r = cur:fetch()
     for k, v in ipairs(r) do
        print(k, v)
     end
end

See more exampes and API doc

About

MySQL 5.5 access for Lua 5.3

License:Apache License 2.0


Languages

Language:C 61.3%Language:HTML 21.4%Language:C++ 10.5%Language:Objective-C 5.3%Language:Makefile 0.6%Language:Lua 0.4%Language:Roff 0.3%Language:CSS 0.1%