lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Yes, you are right. Using sqlite3.exe, I had created the database with these commands:

sqlite3 test.dbl
sqlite> pragma foreign_keys = on;
sqlite> .read test.sql
sqlite> sqlite_version();
3.7.5

and after:

lua test.lua
3.3.17

I created the database with 3.7.5 version, but when running the called version was 3.3.17. I placed sqlite3.exe and Sqlite3.dll in ./clibs and I though it would be sufficient to update my version. However, if I understood the version embedded in luasql is older and there is no support for foreign keys.

In Lua script, I tried also:

cur = con:execute('pragma foreign_keys = on')

But this attempt to enable via code the foreign key for the section doesn't result. Yes, the problem seems to be the old version of Sqlite used by Luasql.

Is the conclusion that I can't use foreign keys with Luasqlite.sqlite3()? If the answer is yes, the alternatives could be:

1. To manage relations among tables not in the database, but in the Lua code. When the number of tables or the number of relations are few, perhaps it would be the easier approach.

2. To change to another database more powerful, supporting foreign keys. But in this case, I don't want a separated process like Mysql.

Regarding a database which can be distributed together with the program without additional instalations and foreign keys support, is there another option of database? Could I use Luasql or should use another Lua module?

Em 13/03/2011 00:11, Bob Chapman escreveu:
On Sat, Mar 12, 2011 at 6:20 PM, Luciano de Souza<luchyanus@gmail.com>  wrote:
Hi all,

I want to use foreign keys in Sqlite3. I am using the modules available in
Lua for Windows and I downloaded the DLL and the commandline tool for
Sqlite3.
Does someone has an idea why I can't use foreign keys?

Does your example work for the command line tool? If so, this might be
the problem:

Lua 5.1.4  Copyright (C) 1994-2008 Lua.org, PUC-Rio
require "luasql.sqlite3"
env = luasql.sqlite3()
con = env:connect("")
cur = con:execute("select sqlite_version()")
print(cur:fetch())
3.3.17<====

[Run using the Lua for Windows package]

--