update readme

This commit is contained in:
Cadey Ratio 2017-07-13 23:40:12 -07:00
parent a70b08e3d7
commit edf576cd33
1 changed files with 9 additions and 10 deletions

View File

@ -62,11 +62,11 @@ conn.SetConsistencyLevel("strong")
conn.SetTimeout(10)
// simulate database/sql Prepare()
statements := make ([]string,0)
pattern := "INSERT INTO secret_agents(id, hero_name, abbrev) VALES (%d, '%s', '%3s')"
statements = append(statements,fmt.Sprintf(pattern,125718,"Speed Gibson","Speed"))
statements = append(statements,fmt.Sprintf(pattern,209166,"Clint Barlow","Clint"))
statements = append(statements,fmt.Sprintf(pattern,44107,"Barney Dunlap","Barney"))
var statements []string
pStmt := NewPreparedStatement("INSERT INTO secret_agents(id, hero_name, abbrev) VALUES (%d %s %3s)")
statements = append(statements, pStmt.Bind(125718, "Speed Gibson", "Speed"))
statements = append(statements, pStmt.Bind(209166, "Clint Barlow", "Clint"))
statements = append(statements, pStmt.Bind(44107, "Barney Dunlap", "Barney"))
results, err := conn.Write(statements)
// now we have an array of []WriteResult
@ -168,7 +168,7 @@ The chief reasons a proper database/sql driver is not possible are:
* As a consequence, there is no rollback.
* The statement parsing/preparation API is not exposed at the SQL layer by sqlite, and hence it's not exposed by rqlite. What this means is that there's no way to prepare a statement (`"INSERT INTO superheroes (?,?)"`) and then later bind executions to it. (In case you're wondering, yes, it would be possible for gorqlite to include a copy of sqlite3 and use its engine, but the sqlite C call to `sqlite3_prepare_v2()` will fail because a local sqlite3 won't know your DB's schemas and the `sqlite3_prepare_v2()` call validates the statement against the schema. We could open the local sqlite .db file maintained by rqlite and validate against that, but there is no way to make a consistency guarantee between time of preparation and execution, especially since the user can mix DDL and DML in a single transaction).
* Prepared statements can be made and used using the `PreparedStatement` type. Create a new PreparedStatement instance with `NewPreparedStatement` with the SQL query as a string argument with sprintf syntax. Do not surround strings in quotes, as the `Bind` call will add those for you. See above for the usage.
* So we've turned off `Begin()`, `Rollback()`, and `Commit()`, and now we need to turn off `Prepare()`.
@ -205,4 +205,3 @@ These can overridden using the environment variables:
## Pronunciation
rqlite is supposed to be pronounced "ree qwell lite". So you could pronounce gorqlite as either "go ree kwell lite" or "gork lite". The Klingon in me prefers the latter. Really, isn't rqlite just the kind of battle-hardened, lean and mean system Klingons would use? **Qapla'!**