2017-07-27 15:00:00 +02:00
2017-07-24 13:00:21 +02:00
2017-07-24 13:21:29 +02:00
boo
2017-07-25 08:25:58 +02:00
2017-07-25 14:35:49 +02:00
2017-07-25 08:25:58 +02:00
2017-07-25 11:09:41 +02:00
2017-07-25 08:34:43 +02:00
2017-07-25 14:12:25 +02:00
2017-07-26 13:37:45 +02:00
2017-07-25 08:34:43 +02:00
2017-07-25 14:12:07 +02:00

gocqlx GoDoc Go Report Card Build Status

Package gocqlx is a gocql extension, similar to what sqlx is to database/sql.

It contains wrappers over gocql types that provide convenience methods which are useful in the development of database driven applications. Under the hood it uses sqlx/reflectx package so sqlx models will also work with gocqlx.

Installation

go get github.com/scylladb/gocqlx

Features

Read all rows into a slice.

var v []*Item
if err := gocqlx.Select(&v, session.Query(`SELECT * FROM items WHERE id = ?`, id)); err != nil {
    log.Fatal("select failed", err)
}

Read a single row into a struct.

var v Item
if err := gocqlx.Get(&v, session.Query(`SELECT * FROM items WHERE id = ?`, id)); err != nil {
    log.Fatal("get failed", err)
}

Bind named query parameters from a struct or map.

stmt, names, err := gocqlx.CompileNamedQuery([]byte("INSERT INTO items (id, name) VALUES (:id, :name)"))
if err != nil {
    t.Fatal("compile:", err)
}
q := gocqlx.Queryx{
    Query: session.Query(stmt),
    Names: names,
}
if err := q.BindStruct(&Item{"id", "name"}); err != nil {
    t.Fatal("bind:", err)
}
if err := q.Query.Exec(); err != nil {
    log.Fatal("get failed", err)
}

Example

See example test.

Description
No description provided
Readme 667 KiB
1.0.0 Latest
2025-11-20 16:10:32 +01:00
Languages
Go 97.2%
Makefile 2.8%