import("nexus.system.data.sqlite")
method main ()
{
path = "c:\\nexus\\test\\data\\sqlite.db"
if {System.IO.File.exists(path) ? System.IO.File.delete(path)}
env = System.Data.SQLite.Environment.new()
conn = env.connect(path)
conn.set_auto_commit(false)
stmt =
[[
CREATE TABLE test
("id" INTEGER PRIMARY KEY NOT NULL,
"name" VARCHAR(64) DEFAULT NULL,
"created" DATETIME DEFAULT NULL);
]]
conn.execute(stmt)
conn.commit()
for (id; 0..500) {
now = System.time(),
dts = ("'" + System.date_format("%Y-%m-%d %H:%M:%S", false, now) + "'")
stmt = "insert into test (id,name,created) values (" + id + ", 'this is sample data', " + dts + ");"
conn.execute(stmt)
}
conn.commit()
for (id; 0..500) {
stmt = "select * from test where id = " + id + ";"
cursor = conn.execute(stmt)
res = cursor.fetch()
print(res)
}
conn.close()
}
main()