Added alternative example

This commit is contained in:
Indribell 2019-01-14 03:23:30 +01:00 committed by GitHub
parent a95182be08
commit eea13c922c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,6 +44,14 @@ DB.open "sqlite3://./data.db" do |db|
end
```
Example 2
```
db = DB.open "sqlite3://./data.db"
db.exec "CREATE TABLE IF NOT EXISTS contacts (name text, age integer)"
db.exec "INSERT INTO contacts VALUES (?, ?)", "John Doe", 30
contacts = db.query_all "SELECT name, age FROM contacts", as: {name: String, age: Int64}
```
### DB::Any
* `Time` is implemented as `TEXT` column using `SQLite3::DATE_FORMAT` format.