DmitrMakeev commited on
Commit
3f95689
1 Parent(s): 9a2cc8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -34
app.py CHANGED
@@ -63,48 +63,42 @@ 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 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 NOT NULL,
76
- chat_id TEXT NOT NULL,
77
- ws_st TEXT NOT NULL,
78
- ws_stop TEXT NOT NULL,
79
- web_st INTEGER,
80
- fin_prog INTEGER,
81
- b_city TEXT NOT NULL,
82
- b_fin TEXT NOT NULL,
83
- b_ban TEXT NOT NULL,
84
- b_ign TEXT NOT NULL,
85
- b_baners TEXT NOT NULL,
86
- b_butt TEXT NOT NULL,
87
- b_mess TEXT NOT NULL,
88
- shop_st TEXT NOT NULL,
89
- curator TEXT NOT NULL,
90
- pr1 TEXT NOT NULL,
91
- pr2 TEXT NOT NULL,
92
- pr3 TEXT NOT NULL,
93
- pr4 TEXT NOT NULL,
94
- pr5 TEXT NOT NULL,
95
- ad_url TEXT NOT NULL,
96
- key_pr TEXT NOT NULL,
97
- n_con TEXT NOT NULL,
98
- canal TEXT NOT NULL,
99
- data_t TEXT NOT NULL
100
- )
101
  ''')
102
  conn.commit()
103
  conn.close()
104
 
105
  for db in DATABASES:
106
- init_db(db)
107
-
108
 
109
 
110
  template = {
 
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 = {