GithubHelp home page GithubHelp logo

troublete / go-luadb Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 1.0 11 KB

A Lua extension for database (Postgres) access.

License: MIT License

Makefile 0.76% Go 99.24%
lua go extension database posgres posgresql lua-extension db golang

go-luadb's Introduction

luadb

a Lua extension for database access

Introduction

This extension provides database access. It currently supports:

  • PostgreSQL

Usage

local db = require('luadb')
db.connect_postgres('postgresql://...') -- connect via connection string

ok = db.ping() -- returns ok if ping successful; or throws an error
rows = db.query('select * from ...') -- runs query and returns rows as table of tables; or throws an error
lastId, rowsAffected = db.exec('insert into ...') -- executes query, and returns state vars as integers; or throws an error

Build

Assumes a Lua version is installed as static lib (liblua.a) (which is standard at least for Lua 5.4) in /usr/local/lib/.

To build run:

make build

DBMS

PostgreSQL

  • Supports mapping for most generic types
    • SMALLINT, INT, BIGINT are returned as integer (which correlates to C double double)
    • REAL, DOUBLE are returned as number (which correlates to C double)
    • CHAR, VARCHAR, TEXT are returned as string
    • DATE, TIME, TIMETZ, TIMESTAMP, TIMESTAMPTZ are returned a ISO8601 representing string
    • BOOL is returned as boolean
    • BYTEA is returned as "byte table"
  • Supports mapping of JSON and JSONB fields to Lua tables
  • Supports mapping of NUMERIC and DECIMAL to numbers
  • All not mapable data is returned as "byte table"

Contribute

It would be nice to grow this library to include also support for other relational DBMS's.

Contributions are welcome.

go-luadb's People

Contributors

troublete avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

xwinie

go-luadb's Issues

SQLite

  • Add SQL Lite Support
    • Add Connector
    • Add Value mapper SQLite > Lua

Postgres: Hstore Support

Add hstore support. This entails creating the binary mapping for hstore and the correct value conversion to a Lua type.

Postgres

  • Add value mapping Postgres > Lua

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.