Hi,

I have started the development of a cassandra cql driver in Lua.

The code is available at https://github.com/jbochi/lua-resty-cassandra.

It is missing some features
<https://github.com/jbochi/lua-resty-cassandra/issues?state=open> and lacks
support for several types
<https://github.com/jbochi/lua-resty-cassandra/issues/16>but is already
usable:

      session = cassandra.new()
      session:set_timeout(1000)
      connected, err = session:connect("127.0.0.1", 9042)

      session:set_keyspace("lua_tests")

      local table_created, err = session:execute([[
          CREATE TABLE users (
            user_id uuid PRIMARY KEY,
            name varchar,
            age int
          )
      ]])

      local ok, err = session:execute([[
        INSERT INTO users (name, age, user_id)
        VALUES (?, ?, ?)
      ]], {"Juarez S' Bochi", 31, {type="uuid",
value="1144bada-852c-11e3-89fb-e0b9a54a6d11"}})
      local users, err = session:execute("SELECT name, age, user_id from
users")
      assert.same(1, #users)
      local user = users[1]
      assert.same("Juarez S' Bochi", user.name)
      assert.same("1144bada-852c-11e3-89fb-e0b9a54a6d11", user.user_id)
      assert.same(31, user.age)
      assert.truthy(ok)


Contributions and suggestions are welcome!

https://github.com/jbochi/lua-resty-cassandra

Thanks,
Juarez Bochi

Reply via email to