Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hoelzro/sqlite-lua-extension
A SQLite extension that embeds a Lua interpreter into SQLite
https://github.com/hoelzro/sqlite-lua-extension
lua sqlite
Last synced: 2 months ago
JSON representation
A SQLite extension that embeds a Lua interpreter into SQLite
- Host: GitHub
- URL: https://github.com/hoelzro/sqlite-lua-extension
- Owner: hoelzro
- License: mit
- Created: 2012-09-25T16:06:25.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2020-06-20T18:28:47.000Z (over 4 years ago)
- Last Synced: 2024-10-04T13:26:08.759Z (3 months ago)
- Topics: lua, sqlite
- Language: C
- Size: 4.88 KB
- Stars: 19
- Watchers: 5
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
- AwesomeInterpreter - sqlite-lua-extension
- awesome-sqlite - github.com/hoelzro/sqlite-lua-extension - Embed a Lua interpreter into SQLite (Extensions)
README
# 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
```sql
select lua('print "hi"');
```## Getting data from Lua
```sql
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:```sql
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:
```sql
select lua('arg[1] ** 2', value) from values; -- squares values
```I may introduce a "nicer" syntax for this in the future.