-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathsql.ai
More file actions
23 lines (20 loc) · 835 Bytes
/
sql.ai
File metadata and controls
23 lines (20 loc) · 835 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use std.db.pg;
pg.query("INSERT INTO language (name) VALUES($1) RETURNING id, name;", "Rust");
let languages = pg.query("select id, name from language;");
print(languages); // expect: [1, "Rust"]
let languages = pg.query_as(Language, "select id, name from language where id > 3 limit 10;");
class Language {
id: int,
name: str,
}
print(languages);
let tx = pg.begin_transaction();
print(tx);
let r1 = tx.query("INSERT INTO language (name) VALUES($1) RETURNING id, name;", "JavaScript");
print(r1);
let r2 = tx.query("INSERT INTO language (name) VALUES($1) RETURNING id, name;", "AIScript");
print(r2);
let languages = pg.query_as(Language, "select id, name from language where id > 10 limit 10;");
print(languages);
tx.commit();
// print(pg.query(r"update language set "name"='aiscript22' where id=38 returning id, name;"));