diff --git a/.gitignore b/.gitignore index 0bb91ef..6b1adcb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ # python cache __pycache__ + +# config files +web/config.php diff --git a/init-db.py b/init-db.py index 6d94d18..b151dfc 100755 --- a/init-db.py +++ b/init-db.py @@ -21,6 +21,7 @@ from common import norm, get_tile_width, get_tile, get_area_name dbuser= "" dbpw = "" +dbname = "worldbuild" force = False argc = len(sys.argv) @@ -32,6 +33,9 @@ while i < argc: elif sys.argv[i] == "-u" or sys.argv[i] == "--user": i += 1 dbuser = sys.argv[i] + elif sys.argv[i] == "-d" or sys.argv[i] == "--database": + i += 1 + dbname = sys.argv[i] elif sys.argv[i] == "-f" or sys.argv[i] == "--force": force = True elif sys.argv[i] == "-h" or sys.argv[i] == "--help": @@ -39,6 +43,7 @@ while i < argc: print("Initializes worldbuild status db") print("") print("OPTIONS") + print(" -d, --database Database to be initialised. Default: worldbuild") print(" -p, --password Database password") print(" -u, --user Database user") print(" -f, --force Recreates everything from scratch") @@ -67,7 +72,7 @@ states = [ ] #try: -db = pymysql.connect("localhost", dbuser, dbpw, "worldbuild") +db = pymysql.connect("localhost", dbuser, dbpw, dbname) cursor = db.cursor() @@ -190,6 +195,8 @@ sql = ('CREATE OR REPLACE TRIGGER update_top_level ' 'END IF; ' 'END; ') cursor.execute(sql) +sql = "CREATE TABLE `auth` (`id` int(11) NOT NULL AUTO_INCREMENT, `token` varchar(100) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `token` (`token`)) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4" +cursor.execute(sql) db.commit() #except: