DmitrMakeev commited on
Commit
2a6271f
1 Parent(s): 3f95689

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -28
app.py CHANGED
@@ -63,42 +63,47 @@ if not os.path.exists(UPLOAD_FOLDER):
63
 
64
  DATABASES = ['data_gc.db', 'data1.db', 'data2.db', 'data3.db', 'data4.db', 'data5.db']
65
 
66
- def alter_db_schema(db_name):
67
  conn = sqlite3.connect(db_name)
68
  cursor = conn.cursor()
69
  cursor.execute('''
70
- ALTER TABLE contacts
71
- ALTER COLUMN vk_id SET DEFAULT NULL,
72
- ALTER COLUMN chat_id SET DEFAULT NULL,
73
- ALTER COLUMN ws_st SET DEFAULT NULL,
74
- ALTER COLUMN ws_stop SET DEFAULT NULL,
75
- ALTER COLUMN web_st SET DEFAULT NULL,
76
- ALTER COLUMN fin_prog SET DEFAULT NULL,
77
- ALTER COLUMN b_city SET DEFAULT NULL,
78
- ALTER COLUMN b_fin SET DEFAULT NULL,
79
- ALTER COLUMN b_ban SET DEFAULT NULL,
80
- ALTER COLUMN b_ign SET DEFAULT NULL,
81
- ALTER COLUMN b_baners SET DEFAULT NULL,
82
- ALTER COLUMN b_butt SET DEFAULT NULL,
83
- ALTER COLUMN b_mess SET DEFAULT NULL,
84
- ALTER COLUMN shop_st SET DEFAULT NULL,
85
- ALTER COLUMN curator SET DEFAULT NULL,
86
- ALTER COLUMN pr1 SET DEFAULT NULL,
87
- ALTER COLUMN pr2 SET DEFAULT NULL,
88
- ALTER COLUMN pr3 SET DEFAULT NULL,
89
- ALTER COLUMN pr4 SET DEFAULT NULL,
90
- ALTER COLUMN pr5 SET DEFAULT NULL,
91
- ALTER COLUMN ad_url SET DEFAULT NULL,
92
- ALTER COLUMN key_pr SET DEFAULT NULL,
93
- ALTER COLUMN n_con SET DEFAULT NULL,
94
- ALTER COLUMN canal SET DEFAULT NULL,
95
- ALTER COLUMN data_t SET DEFAULT NULL;
 
 
 
 
 
96
  ''')
97
  conn.commit()
98
  conn.close()
99
 
100
  for db in DATABASES:
101
- alter_db_schema(db)
102
 
103
 
104
  template = {
 
63
 
64
  DATABASES = ['data_gc.db', 'data1.db', 'data2.db', 'data3.db', 'data4.db', 'data5.db']
65
 
66
+ def init_db(db_name):
67
  conn = sqlite3.connect(db_name)
68
  cursor = conn.cursor()
69
  cursor.execute('''
70
+ CREATE TABLE IF NOT EXISTS contacts (
71
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
72
+ name TEXT NOT NULL,
73
+ phone TEXT NOT NULL,
74
+ email TEXT NOT NULL,
75
+ vk_id TEXT,
76
+ chat_id TEXT,
77
+ ws_st TEXT,
78
+ ws_stop TEXT,
79
+ web_st INTEGER,
80
+ fin_prog INTEGER,
81
+ b_city TEXT,
82
+ b_fin TEXT,
83
+ b_ban TEXT,
84
+ b_ign TEXT,
85
+ b_baners TEXT,
86
+ b_butt TEXT,
87
+ b_mess TEXT,
88
+ shop_st TEXT,
89
+ curator TEXT,
90
+ pr1 TEXT,
91
+ pr2 TEXT,
92
+ pr3 TEXT,
93
+ pr4 TEXT,
94
+ pr5 TEXT,
95
+ ad_url TEXT,
96
+ key_pr TEXT,
97
+ n_con TEXT,
98
+ canal TEXT,
99
+ data_t TEXT
100
+ )
101
  ''')
102
  conn.commit()
103
  conn.close()
104
 
105
  for db in DATABASES:
106
+ init_db(db)
107
 
108
 
109
  template = {