blob: 1efbb181afdd12b611c65b48c5f8b19960fedba3 (
plain)
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
41
42
43
44
45
46
47
48
|
module captain_db
use sqlite
implicit none
character(1024)::database_file
type(c_ptr)::db
contains
subroutine initialize_db(filename)
implicit none
character(*), intent(in)::filename
if(sqlite3_open(filename, db) == SQLITE_OK) then
database_file = filename
else
Print *, "ERROR: Could not open db"
stop
end if
end subroutine initialize_db
subroutine shutdown_db()
implicit none
integer::i
i = sqlite3_close(db)
end subroutine shutdown_db
subroutine add_player_db(name, token)
implicit none
character(*), intent(in)::name, token
type(sqlite3_stmt)::stmt
if(stmt%prepare(db, "INSERT INTO players(name, token) VALUES(?, ?)") == SQLITE_OK) then
if(stmt%bind_text(1, "name!") == SQLITE_OK .and. stmt%bind_text(2, "token!") == SQLITE_OK) then
call stmt%step_now()
end if
end if
call stmt%finalize()
end subroutine add_player_db
end module captain_db
|