cassandra-client-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juarez Bochi <jbo...@gmail.com>
Subject Lua CQL driver
Date Wed, 09 Jul 2014 21:32:33 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message