user2566212
user2566212

Reputation:

Install luaSQL on Ubuntu

TL;DR: You can skip to here. I was trying to use luarocks installer, but the apt-get installer did it without problems.


I am experiencing issues when installing luaSQL on Ubuntu. I need it for a script that uses luasql = require "luasql.mysql". I followed the official documentation which can be found here: http://keplerproject.github.io/luasql/doc/us/
What I've tried (and what was suggested by the official documentation):

sudo luarocks install luasql-mysql

gave me the following output:

Error: Could not find expected file mysql.h for MYSQL -- 
you may have to install MYSQL in your system and/or pass MYSQL_DIR or 
MYSQL_INCDIR to the luarocks command. Example: luarocks install luasql-mysql
MYSQL_DIR=/usr/local

So I first had to get the mysql.h file. After some googling I found this:

sudo apt-get update
sudo apt-get install libmysqlclient-dev 

So I tried my first command again, but with the location of the mysql.h file as parameter:

sudo luarocks install luasql-mysql MYSQL_DIR=/usr/include/mysql

And it gave me the same error as in the beginning. Does anyone know the right instructions for installing luaSQL on an Ubuntu machine? Or can point me in the right direction?


My system:
Description: Ubuntu 14.04.2 LTS
Release: 14.04
Codename: trusty

Upvotes: 1

Views: 4766

Answers (4)

Cr4xy
Cr4xy

Reputation: 179

If you want to install it manually:

apt-get install -y libmysqlclient-dev git
luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql

Upvotes: 1

mirkobrankovic
mirkobrankovic

Reputation: 2347

I had to use MYSQL_INCDIR

sudo luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql

Cause it failed with MYSQL_DIR

Upvotes: 0

AaronDanielson
AaronDanielson

Reputation: 2460

The apt installer didn't do it for me.

I was able to install it from source on github (keplerproject/luasql) by modifying the config file. Lua 5.2 was hard-coded in the config file, but I'm running 5.1.

In the config file, replace LUA_SYS_VER ?= 5.2 with LUA_SYS_VER ?= 5.1

Upvotes: 0

user2566212
user2566212

Reputation:

to install LuaSQL:

apt-get install lua-sql-mysql

Credits to user 'TsT' from the irc chat of lua-support: the chatlog can be found here: https://botbot.me/freenode/lua-support/msg/50072546/


A test script you can use:

luasql = require "luasql.mysql"

env = assert (luasql.mysql())
con = assert (env:connect("dbname","username","password","host.com"))
cur = assert (con:execute("INSERT INTO `table`(`col_int`,`col_varchar`) VALUES (9,'Hi')"))

Upvotes: 7

Related Questions