Giter Site home page Giter Site logo

lsqlite's Introduction

LSQlite

Lsqlite is a simple sqlite module i wrote back in 2010. It is still fully functional with lua 5.3 as of end 2017.

Update: It's 2020 and I had to change two lines.

SYNOPSIS

lsqlite = require("lsqlite")

local db = lsqlite.open(database)
db:exec(statements)
db:close(db)

SUMMARY

The lsqlite module is a minimalistic sqlite3 - lua module. You can open a database, perform any sqlite statements on it and close it. If you don't close the database, the garbage collector will do this for you.

DESCRIPTION

  • lsqlite.open(database) returns an lsqlite object or nil
  • db:exec(statements) executes one or more sqlite statments in one string and returns the output and an error description, if any
  • db:close() closes an open database

BUILDING

  • building the library requires gcc with version < 9.
  • for gcc-9/-10 see TROUBLE SHOOTING

EXAMPLE

lsqlite = require("lsqlite")

local db = lsqlite.open("database.sqlite")
local results, error = db:exec("select * from my_table;")
for i=1,#results do
    for k,v in pairs(results[i]) do
        print(k,v)
    end
end
db:close(db)

SPECIAL FILES

To open an in memory database try

lsqlite = require("lsqlite")

local db = lsqlite.open(":memory:")

TROUBLE SHOOTING

Currently there is an issue linking to the shared sqlite3.so on Debian with gcc-9/-10. You may use the Makefile-Amalgamed to overcome this problem.

For this to work you must place sqlite3.c and sqlite3.h from an archive downloaded from https://www.sqlite.org/download.html in this directory.

Compilation:

make -f Makefile-Amalgamed

COPYRIGHT

Copyright ยฉ 2010-2020 by Nico Hoffmann. License is MIT. For the complete text see the supplied documentation.

lsqlite's People

Contributors

maxdoom-com avatar thchha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lsqlite's Issues

building with gcc > 8?

Hey, thanks for your library - satisfies exactly my needs! :- )

I can't build your library on Debian bullseye AMD64, which only comes with > gcc-8.

After building and referencing the .so, my scripts report an error, same for the provided test.lua:

lua: error loading module 'lsqlite' from file '/home/...../lsqlite.so':
path/repeated/lsqlite.so undefined symbol: sqlite3_exec

So i tried compiling with gcc-8, 9, 10, c99, with lua 5.1 and lua 5.3 (including compat).
When compiling with lua 5.3, luaL_open can not be found.

where libsqllite3-dev is the version 3.31.1-5.
on ARM64 (using Lua 5.1 || 5.3) version: 3.27.2-3 it is working as expected! ๐Ÿ‘

Before asking, i checked the news on sqlite.org. The function sqlite_exec() is still listed in their API, so I am not able to resolve this on my own :- (

Applications that use SQLite should only interface with SQLite through the officially published APIs. Applications should not depend upon or use the internal data structures of SQLite as those structures might change from one release to another. However, there is a popular application that does depend on the details of the internal layout of data in an internal SQLite data structure, and those details changed in version 3.31.0, breaking the application. This is, technically, a bug in the application, not in SQLite. But it is within the power of SQLite to fix it, by reverting the internal data structure change, and so that is what we have done for the 3.31.1 release.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.