Skip to content

hoelzro/sqlite-lua-extension

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

SQLite-Lua - Lua extension for SQLite

This SQLite extension embeds a Lua interpeter into SQLite, so you can execute Lua code in your SQL statements.

Examples

Executing Lua code

  select lua('print "hi"');

Getting data from Lua

  select lua('return math.random(1, 10)');

Since the 'return' is annoying to type and is easy to forget, the extension automatically prepends a 'return' if it doesn't result in a syntax error:

  select lua('math.random(1, 10)') -- same as above

Returning values of a type that doesn't have a sensible equivalent in SQLite (tables, functions, userdata, and coroutines) causes an error.

Returned booleans are converted into integers.

Passing data to Lua

Values passed after the Lua statement are passed into the Lua chunk via a table named arg:

  select lua('arg[1] ** 2', value) from values; -- squares values

I may introduce a "nicer" syntax for this in the future.

About

A SQLite extension that embeds a Lua interpreter into SQLite

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages