Now not create the database if exists

This commit is contained in:
Antonio de la Rosa 2016-08-05 02:30:38 +02:00
parent 97367ba2c0
commit 16fa9b550a
2 changed files with 52 additions and 49 deletions

View file

@ -219,17 +219,22 @@ def start():
useradmin=UserAdmin(conn) useradmin=UserAdmin(conn)
if not useradmin.query(sql):
#print('Error: cannot create database, check the data of database')
# Check if db exists # Check if db exists
cur=useradmin.query('SHOW DATABASES LIKE "%s"' % db) c=0
if cur.rowcount()==0: with useradmin.query('SHOW DATABASES LIKE "%s"' % db) as cur:
print('Error: cannot create database or db doesn\'t exists, check database permissions for this user') c=cur.rowcount
else: if c==0:
useradmin.query(sql)
#print('Error: cannot create database or db doesn\'t exists, check database permissions for this user')
#if not useradmin.query(sql):
#print('Error: cannot create database, check the data of database')
#else:
useradmin.query('use '+db) useradmin.query('use '+db)
@ -276,7 +281,7 @@ def start():
except: except:
print('Error: cannot copy the file padmin.py. Check if exists and if you have permissions for this task') print('Error: cannot create the database. Check if tables exists in it and if you have permissions for this task')
exit(1) exit(1)
pass pass

View file

@ -50,12 +50,10 @@ env=env_theme(__file__)
menu=get_menu(config_admin.modules_admin) menu=get_menu(config_admin.modules_admin)
#arr_admin_modules={for k, in menu}
#d = {key: value[1] for (key, value) in menu.items()}
module_imported={} module_imported={}
for k, v in menu.items(): for k, v in menu.items():
#print(k[:1])
if k[:1]!='/': if k[:1]!='/':
if type(v).__name__=='list': if type(v).__name__=='list':
module_imported[k]=import_module(v[1]) module_imported[k]=import_module(v[1])