<commit_before>lua-resty-cassandra
===================

[![Build Status](https://travis-ci.org/jbochi/lua-resty-cassandra.svg?branch=master)](https://travis-ci.org/jbochi/lua-resty-cassandra)

Cassandra client for Lua Nginx module using CQL binary protocol v2.

This is a work in progress and is definitly not ready for production use, but
all important features work: prepare and execute queries with arguments of
the basic types.

API
---
```lua
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 (?, ?, ?)
]], {"<NAME>", 42, cassandra.uuid("1144bada-852c-11e3-89fb-e0b9a54a6d11")})
local users, err = session:execute("SELECT name, age, user_id from users")
assert(1 == #users)
local user = users[1]
ngx.say(user.name) -- "<NAME>"
ngx.say(user.user_id) -- "1144bada-852c-11e3-89fb-e0b9a54a6d11"<commit_msg>README: Add require<commit_after>lua-resty-cassandra
===================

[![Build Status](https://travis-ci.org/jbochi/lua-resty-cassandra.svg?branch=master)](https://travis-ci.org/jbochi/lua-resty-cassandra)

Cassandra client for Lua Nginx module using CQL binary protocol v2.

This is a work in progress and is definitly not ready for production use, but
all important features work: prepare and execute queries with arguments of
the basic types.

API
---
```lua
cassandra = require("cassandra")
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 (?, ?, ?)
]], {"<NAME>", 42, cassandra.uuid("1144bada-852c-11e3-89fb-e0b9a54a6d11")})
local users, err = session:execute("SELECT name, age, user_id from users")
assert(1 == #users)
local user = users[1]
ngx.say(user.name) -- "<NAME>"
ngx.say(user.user_id) -- "1144bada-852c-11e3-89fb-e0b9a54a6d11"
{'fraction_non_alphanumeric': 0.156589821661592, 'fraction_numerical': 0.049586776859504134, 'mean_word_length': 4.693069306930693, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3152405', 'n_tokens_mistral': 896, 'n_tokens_neox': 825, 'n_words': 203}