def execute(form) :
	query = form.get("query")
	res = None
	try :
		res = Database.exeq(query)
	except Exception as e :
		flash(e, Config.Flash.error)
	else :
		flash(u"Befehl erfolgreich ausgeführt!", Config.Flash.success)
	return view(query, res)
Ejemplo n.º 2
0
def createTables(log = Log.info) :
	log("Creating table 'users'...")
	Database.exeq("CREATE TABLE users (username varchar(255) PRIMARY KEY, password varchar(255), role varchar(255));")
	log("Table 'users' created.")

	log("Creating table 'courses'...")
	Database.exeq("CREATE TABLE courses (id serial PRIMARY KEY, username varchar(255) REFERENCES users (username) ON UPDATE CASCADE ON DELETE CASCADE, name varchar(255), date varchar(255), time varchar(255), role varchar(255));")
	log("Table 'courses' created.")

	log("Creating table 'sheets'...")
	Database.exeq("CREATE TABLE sheets (id serial PRIMARY KEY, username varchar(255) REFERENCES users (username) ON UPDATE CASCADE ON DELETE CASCADE, courses text);")
	log("Table 'sheets' created.")
Ejemplo n.º 3
0
def grantAdminRights(log = Log.info) :
	log("Granting admin rights to all users...")
	Database.exeq("UPDATE users SET role=%s;", Config.User.Roles.admin)
	log("Rights granted.")