-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdbi.jl
40 lines (27 loc) · 850 Bytes
/
dbi.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
module TestDBI
using DBI
using MySQL
db = connect(MySQL5, "127.0.0.1", "root", "KF4BvgkhFqd9", "jmw")
sql = "CREATE TABLE users (id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255))"
stmt = prepare(db, sql)
execute(stmt)
try
stmt = prepare(db, sql)
execute(stmt)
end
errcode(db)
errstring(db)
rowid = lastinsertid(db)
stmt = prepare(db, "INSERT INTO users (name) VALUES ('Jeff Bezanson')")
execute(stmt)
stmt = prepare(db, "INSERT INTO users (name) VALUES ('Viral Shah')")
execute(stmt)
stmt = prepare(db, "INSERT INTO users (name) VALUES ('Stefan Karpinski')")
execute(stmt)
rowid = lastinsertid(db)
stmt = prepare(db, "DROP TABLE users")
execute(stmt)
# TODO: Rename this
safesql = sqlescape(db, "Viral's")
disconnect(db)
end