ソースを参照

not null 제거 및 정리

2DU 9 年 前
コミット
81f8b3f7d9
1 ファイル変更45 行追加22 行削除
  1. 45 22
      app.py

+ 45 - 22
app.py

@@ -24,100 +24,123 @@ app.config['MAX_CONTENT_LENGTH'] = int(data['upload']) * 1024 * 1024
 try:
     conn = pymysql.connect(host = data['host'], user = data['user'], password = data['pw'], db = data['db'], charset = 'utf8mb4')
     curs = conn.cursor(pymysql.cursors.DictCursor)
+    
     try:
         curs.execute("select * from data limit 1")
     except:
-        curs.execute("create table data(title text not null, data longtext not null, acl text not null)")
+        curs.execute("create table data(title text, data longtext, acl text)")
+    
     try:
         curs.execute("select * from history limit 1")
     except:
-        curs.execute("create table history(id text not null, title text not null, data longtext not null, date text not null, ip text not null, send text not null, leng text not null)")
+        curs.execute("create table history(id text, title text, data longtext, date text, ip text, send text, leng text)")
+    
     try:
         curs.execute("select * from rd limit 1")
     except:
-        curs.execute("create table rd(title text not null, sub text not null, date text not null)")
+        curs.execute("create table rd(title text, sub text, date text)")
+    
     try:
         curs.execute("select * from user limit 1")
     except:
-        curs.execute("create table user(id text not null, pw text not null, acl text not null)")
+        curs.execute("create table user(id text, pw text, acl text)")
+    
     try:
         curs.execute("select * from ban limit 1")
     except:
-        curs.execute("create table ban(block text not null, end text not null, why text not null, band text not null)")
+        curs.execute("create table ban(block text, end text, why text, band text)")
+    
     try:
         curs.execute("select * from topic limit 1")
     except:
-        curs.execute("create table topic(id text not null, title text not null, sub text not null, data longtext not null, date text not null, ip text not null, block text not null)")
+        curs.execute("create table topic(id text, title text, sub text, data longtext, date text, ip text, block text)")
+    
     try:
         curs.execute("select * from stop limit 1")
     except:
-        curs.execute("create table stop(title text not null, sub text not null, close text not null)")
+        curs.execute("create table stop(title text, sub text, close text)")
+    
     try:
         curs.execute("select * from rb limit 1")
     except:
-        curs.execute("create table rb(block text not null, end text not null, today text not null, blocker text not null, why text not null)")
+        curs.execute("create table rb(block text, end text, today text, blocker text, why text)")
+    
     try:
         curs.execute("select * from login limit 1")
     except:
-        curs.execute("create table login(user text not null, ip text not null, today text not null)")
+        curs.execute("create table login(user text, ip text, today text)")
+    
     try:
         curs.execute("select * from back limit 1")
     except:
-        curs.execute("create table back(title text not null, link text not null, type text not null)")
+        curs.execute("create table back(title text, link text, type text)")
+    
     try:
         curs.execute("select * from cat limit 1")
     except:
-        curs.execute("create table cat(title text not null, cat text not null)")
+        curs.execute("create table cat(title text, cat text)")
 except:
     conn = pymysql.connect(host = data['host'], user = data['user'], password = data['pw'], charset = 'utf8mb4')
     curs = conn.cursor(pymysql.cursors.DictCursor)
+    
     curs.execute("create database " + data['db'])
     curs.execute("alter database " + data['db'] + " character set = utf8mb4 collate = utf8mb4_unicode_ci")
     curs.execute("use " + data['db'])    
+    
     try:
         curs.execute("select * from data limit 1")
     except:
-        curs.execute("create table data(title text not null, data longtext not null, acl text not null)")
+        curs.execute("create table data(title text, data longtext, acl text)")
+    
     try:
         curs.execute("select * from history limit 1")
     except:
-        curs.execute("create table history(id text not null, title text not null, data longtext not null, date text not null, ip text not null, send text not null, leng text not null)")
+        curs.execute("create table history(id text, title text, data longtext, date text, ip text, send text, leng text)")
+    
     try:
         curs.execute("select * from rd limit 1")
     except:
-        curs.execute("create table rd(title text not null, sub text not null, date text not null)")
+        curs.execute("create table rd(title text, sub text, date text)")
+    
     try:
         curs.execute("select * from user limit 1")
     except:
-        curs.execute("create table user(id text not null, pw text not null, acl text not null)")
+        curs.execute("create table user(id text, pw text, acl text)")
+    
     try:
         curs.execute("select * from ban limit 1")
     except:
-        curs.execute("create table ban(block text not null, end text not null, why text not null, band text not null)")
+        curs.execute("create table ban(block text, end text, why text, band text)")
+    
     try:
         curs.execute("select * from topic limit 1")
     except:
-        curs.execute("create table topic(id text not null, title text not null, sub text not null, data longtext not null, date text not null, ip text not null, block text not null)")
+        curs.execute("create table topic(id text, title text, sub text, data longtext, date text, ip text, block text)")
+    
     try:
         curs.execute("select * from stop limit 1")
     except:
-        curs.execute("create table stop(title text not null, sub text not null, close text not null)")
+        curs.execute("create table stop(title text, sub text, close text)")
+    
     try:
         curs.execute("select * from rb limit 1")
     except:
-        curs.execute("create table rb(block text not null, end text not null, today text not null, blocker text not null, why text not null)")
+        curs.execute("create table rb(block text, end text, today text, blocker text, why text)")
+    
     try:
         curs.execute("select * from login limit 1")
     except:
-        curs.execute("create table login(user text not null, ip text not null, today text not null)")
+        curs.execute("create table login(user text, ip text, today text)")
+    
     try:
         curs.execute("select * from back limit 1")
     except:
-        curs.execute("create table back(title text not null, link text not null, type text not null)")
+        curs.execute("create table back(title text, link text, type text)")
+    
     try:
         curs.execute("select * from cat limit 1")
     except:
-        curs.execute("create table cat(title text not null, cat text not null)")
+        curs.execute("create table cat(title text, cat text)")
 
 app.secret_key = data['key']