-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildDB.py
58 lines (38 loc) · 1.5 KB
/
buildDB.py
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
import sqlite3
conn = sqlite3.connect('redis_aof.db')
c = conn.cursor()
c.execute('''CREATE TABLE KEY_INFO
(KEY_NAME TEXT PRIMARY KEY NOT NULL,
TYPE CHAR(50) NOT NULL,
ENCODING CHAR(50),
BYTE INT,
LENGTH INT);''')
c.execute('''CREATE TABLE STRING_KEY
(KEY_NAME TEXT PRIMARY KEY NOT NULL,
VALUE TEXT NOT NULL);''')
c.execute('''CREATE TABLE LIST_KEY
(KEY_NAME TEXT PRIMARY KEY NOT NULL,
VALUE TEXT NOT NULL
);''')
c.execute('''CREATE TABLE HASH_KEY
(KEY_NAME TEXT NOT NULL,
CHILD_KEY TEXT NOT NULL,
VALUE TEXT NOT NULL,
LEN1 INT,
LEN2 INT,
PRIMARY KEY(KEY_NAME,CHILD_KEY));''')
c.execute('''CREATE INDEX index_hash on HASH_KEY (KEY_NAME);''')
c.execute('''CREATE TABLE SET_KEY
(KEY_NAME TEXT NOT NULL,
VALUE TEXT NOT NULL,
PRIMARY KEY(KEY_NAME,VALUE));''')
c.execute('''CREATE INDEX index_set on SET_KEY (KEY_NAME);''')
c.execute('''CREATE TABLE ZSET_KEY
(KEY_NAME TEXT NOT NULL,
VALUE TEXT NOT NULL,
SCORE REAL,
LEN1 INT,
PRIMARY KEY(KEY_NAME,VALUE));''')
c.execute('''CREATE INDEX index_zset on ZSET_KEY (KEY_NAME);''')
conn.commit()
conn.close()