sqlite: use in-memory database in examples and tests
parent
32473eeafe
commit
3643dcbf4b
|
@ -1,8 +1,7 @@
|
||||||
import sqlite
|
import sqlite
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
/*
|
db := sqlite.connect(':memory:')
|
||||||
db := sqlite.connect('users.db')
|
|
||||||
db.exec("create table users (id integer primary key, name text default '');")
|
db.exec("create table users (id integer primary key, name text default '');")
|
||||||
|
|
||||||
db.exec("insert into users (name) values ('Sam')")
|
db.exec("insert into users (name) values ('Sam')")
|
||||||
|
@ -19,5 +18,4 @@ fn main() {
|
||||||
for row in users {
|
for row in users {
|
||||||
println(row.vals)
|
println(row.vals)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import os
|
|
||||||
import sqlite
|
import sqlite
|
||||||
|
|
||||||
fn test_sqlite() {
|
fn test_sqlite() {
|
||||||
db_file := 'users.db'
|
db := sqlite.connect(':memory:')
|
||||||
db := sqlite.connect(db_file)
|
|
||||||
db.exec("drop table if exists users")
|
db.exec("drop table if exists users")
|
||||||
db.exec("create table users (id integer primary key, name text default '');")
|
db.exec("create table users (id integer primary key, name text default '');")
|
||||||
|
|
||||||
|
@ -22,5 +20,4 @@ fn test_sqlite() {
|
||||||
for row in users {
|
for row in users {
|
||||||
println(row.vals)
|
println(row.vals)
|
||||||
}
|
}
|
||||||
os.rm(db_file)
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue