cgitb.enable() sys.stdout.write('Content-Type: application/octet-stream\n\n') sys.stdout.flush() args = cgi.FieldStorage() dataset = int(args['d'].value) key = args['key'].value if 'key' in args else '' rate = float(args['rate'].value) if 'rate' in args else None start = float(args['start'].value) if 'start' in args else None end = float(args['end'].value) if 'end' in args else None db = MySQLdb.connect(HOST, USER, PASSWORD, DB, cursorclass=cursors.SSCursor) try: cursor = db.cursor() protect_dataset(cursor, dataset) pack_t = struct.Struct('<d') interval = '' if start is not None: interval += f' AND `t` >= {start}' if end is not None: interval += f' AND `t` < {end}' if key != '': query = 'SELECT `data_type`, `column_type` FROM INFORMATION_SCHEMA.COLUMNS WHERE ' + \ '`table_name` = %s AND `column_name` = %s;' cursor.execute(query, (f'dataset_{dataset}', key)) row = cursor.fetchone() sql_type = row[0] + (' unsigned'
sys.stdout.flush() args = cgi.FieldStorage() dataset = int(args['d'].value) project = args['project'].value.lower() if 'project' in args else None description = args['description'].value if 'description' in args else None # TODO: Migrate to POST if possible. db = MySQLdb.connect(HOST, USER, PASSWORD, DB) try: db.autocommit(True) cursor = db.cursor() if project is not None or description is not None: protect_dataset(cursor, dataset, protect_user=True, forbid_guest=True) if project is not None: cursor.execute( f'UPDATE `datasets` SET `project` = %s WHERE `id` = {dataset};', (project, )) if description is not None: cursor.execute( f'UPDATE `datasets` SET `description` = %s WHERE `id` = {dataset};', (description, )) cursor.execute( 'SELECT `owner`, `description`, `project` FROM `datasets` ' + f'WHERE `id` = {dataset};') row = cursor.fetchone()