Repository navigation
Expand file tree
/
Copy pathdata_base_cofig.py
More file actions
115 lines (98 loc) · 2.9 KB
/
Copy pathdata_base_cofig.py
File metadata and controls
115 lines (98 loc) · 2.9 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import psycopg2
from psycopg2 import Error
connection = psycopg2.connect( host="",
port = 0000,
database="",
user="",
password="")
cursor = connection.cursor()
cursor.execute(
'CREATE TABLE gp( '+
"gp_id BIGSERIAL PRIMARY KEY,"+
"channel_id BIGSERIAL,"+
"days int ,"+
"owner_id BIGSERIAL,"+
"check_gif BOOLEAN NOT NULL DEFAULT 'f',"+
"check_stick BOOLEAN NOT NULL DEFAULT 'f',"+
"check_text BOOLEAN NOT NULL DEFAULT 'f',"+
"check_video BOOLEAN NOT NULL DEFAULT 'f',"+
"check_voice BOOLEAN NOT NULL DEFAULT 'f' ,"+
"check_photo BOOLEAN NOT NULL DEFAULT 'f' ,"+
"check_id BOOLEAN NOT NULL DEFAULT 'f',"+
"check_link BOOLEAN NOT NULL DEFAULT 'f',"+
"check_all BOOLEAN NOT NULL DEFAULT 'f',"+
"check_hashtag BOOLEAN NOT NULL DEFAULT 'f',"+
"date_start DATE"+
");"
)
connection.commit()
cursor.execute(
"CREATE TABLE gp_ad("+
"admin_id BIGSERIAL,"+
"gp_id BIGSERIAL,"+
"FOREIGN KEY(gp_id) "+
"REFERENCES gp(gp_id) on delete cascade,"+
"PRIMARY KEY (admin_id, gp_id));"
)
connection.commit()
cursor.execute(
"CREATE TABLE vizir("+
"admin_id BIGSERIAL,"+
"gp_id BIGSERIAL,"+
"FOREIGN KEY(gp_id) "+
"REFERENCES gp(gp_id) on delete cascade,"+
"PRIMARY KEY (admin_id, gp_id));"
)
connection.commit()
cursor.execute("CREATE TABLE gp_lock_word("+
"word VARCHAR(15),"+
"gp_id BIGSERIAL,"+
"FOREIGN KEY(gp_id) "+
"REFERENCES gp(gp_id) on delete cascade,"+
"PRIMARY KEY (word, gp_id));")
connection.commit()
cursor.execute("CREATE TABLE gp_lock_user("+
"person_id BIGSERIAL,"+
"gp_id BIGSERIAL,"+
"FOREIGN KEY(gp_id)" +
"REFERENCES gp(gp_id) on delete cascade,"+
"PRIMARY KEY (person_id, gp_id));")
connection.commit()
cursor.execute("CREATE TABLE warning_member ("+
"person_id BIGSERIAL,"+
"gp_id BIGSERIAL,"+
"count INT DEFAULT 0,"+
"FOREIGN KEY(gp_id) "+
"REFERENCES gp(gp_id) on delete cascade,"+
"PRIMARY KEY (person_id, gp_id));")
connection.commit()
cursor.execute("CREATE TABLE gp_vip("+
"person_id BIGSERIAL,"+
"gp_id BIGSERIAL,"+
"FOREIGN KEY(gp_id) "+
"REFERENCES gp(gp_id) on delete cascade,"+
"PRIMARY KEY (person_id, gp_id));")
connection.commit()
cursor.execute("CREATE TABLE gp_tabchi("+
"person_id BIGSERIAL,"+
"admin_id BIGSERIAL,"+
"gp_id BIGSERIAL,"+
"FOREIGN KEY(gp_id) "+
"REFERENCES gp(gp_id) on delete cascade,"+
"PRIMARY KEY (person_id));")
connection.commit()
cursor.execute("CREATE TABLE kings(" +
"admin_id BIGSERIAL,"+
"PRIMARY KEY (admin_id));")
connection.commit()
cursor.execute("CREATE VIEW vips AS "+
"select owner_id,gp_id from gp "+
"UNION "+
"select admin_id,gp_id from gp_ad "+
"UNION "+
"select person_id,gp_id from gp_vip "+
"UNION "+
"select admin_id,gp_id from vizir "+
"UNION "+
"select admin_id,NULL from kings;")
connection.commit()