-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsql_queries.go
52 lines (45 loc) · 1.11 KB
/
sql_queries.go
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
49
50
51
52
package users
// creates table users in Postgres db
var statementPostgresCreateTableUsers = `
CREATE TABLE IF NOT EXISTS users (
username varchar(90) primary key,
secret varchar(150) not null,
enabled bool default true,
attrs bytea,
created timestamp with time zone not null default now(),
updated timestamp with time zone not null default now()
)`
// creates table users in SQLite db
var statementSQLiteCreateTableUsers = `
CREATE TABLE IF NOT EXISTS users (
username text primary key,
secret text not null,
enabled bool,
attrs blob,
created datetime,
updated datetime
)`
var (
statementGet = `
SELECT username, secret, enabled, attrs, created, updated
FROM users
WHERE username = $1`
statementPut = `
INSERT INTO users (username, secret, enabled, attrs, created, updated)
VALUES ($1, $2, $3, $4, $5, $6)`
statementUpd = `
UPDATE users SET
secret = $1,
enabled = $2,
attrs = $3,
updated = $4
WHERE username = $5`
statementRenameUsr = `
UPDATE users SET
username = $1,
updated = $2
WHERE username = $3`
statementDel = `
DELETE FROM users
WHERE username = $1`
)