Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (24 sloc) 933 Bytes
// make sure FMDB.jstalkextra is installed in your ~/Library/Application Support/JSTalk/Plug-ins/ folder first.
// otherwise, this script isn't going to work so well.
var dbPath = "/tmp/jstalk.sqlite";
var db = [JSTDatabase databaseWithPath:dbPath];
if (![db open]) {
print("Could not open database");
}
[db executeUpdate:"create table test (a text, b text, c integer, d double, e double)"];
[db beginTransaction];
var i = 0;
while (i++ < 20) {
[db executeUpdate:"insert into test (a, b, c, d, e) values (?, ?, ?, ?, ?)" ,
@"hi'", // look! I put in a ', and I'm not escaping it!
"Hello",
i,
[NSDate date],
2.2];
}
[db commit];
var rs = [db executeQuery:"select rowid,* from test where a = ?", "hi'"];
while ([rs next]) {
print([rs stringForColumn:"rowid"] + " " + [rs stringForColumn:"a"] + " " + [rs stringForColumnIndex:2] + " " + [rs dateForColumn:"d"]);
}
[db close];
Jump to Line
Something went wrong with that request. Please try again.