The wrapper library for executing INSERT/UPDATE/DELETE sql query on Google Cloud Spanner.
From version 0.22, Bolt does not support Scala 2.11 due to dependent libraries.
Write library dependency to .sbt file
libraryDependencies += "com.sopranoworks" %% "bolt" % "0.14"
And then,
import Bolt._
dbClinet.executeQuery("INSERT INTO test_tbl01 VALUES(103,'test insert');")
It uses implicit conversion.
You can use it as explicitly like this.
Nut(dbClient).executeQuery("INSERT INTO test_tbl01 VALUES(103,'test insert');")
A transaction query can be used as this.
dbClient.beginTransaction {
tr =>
tr.executeQuery("INSERT INTO test_tbl01 VALUES(103,'test insert');")
}
ResultSet can be used as Iterator.
dbClient.executeQuery("SELECT * FROM test_tbl01").map {
resultSet =>
(resultSet.getString("id"),resultSet.getString("name"))
}
And also
dbClient.executeQuery("SELECT * FROM test_tbl01").headOption
You can use ResultSet safely like this.
dbClient.executeQuery("SELECT * FROM test_tbl01").autoclose(
resultSet =>
...
)
See NutTest.scala
import com.sopranoworks.bolt.Bolt;
Bolt.Nut nut = Bolt.Nut(client);
nut.executeQuery("INSERT INTO TEST_TABLE (ID,NAME) VALUES(101,'test');");
This project also contains console spanner client application, spanne-cli.
This is a bonus program. It will dump a spanner database to sql text code.
A Nut instance is not thread safe. You must create a instance per thread.
- Bytes type is currently not supported in an INSERT/UPDATE query.
- Only few functions are usable in an INSERT/UPDATE query.
- CASE Conditional expression is currently not supported in an INSERT/UPDATE query.
- UNNEST operation is currently not supported in an INSERT/UPDATE query.
There is no such a limitation in SELECT and subquery.
- Referencing outside (INSERT/UPDATE statement's) alias in subquery is not supported in an INSERT/UPDATE query.
- Some literals are currently not supported.
MIT