#NEWLINE# @ has_access #NEWLINE# @ expose ( '/sql/<database_id>/' ) #NEWLINE# @ log_this #NEWLINE# def sql( self , database_id ) : #NEWLINE# #INDENT# if ( not self . appbuilder . sm . has_access ( 'all_datasource_access' , 'all_datasource_access' ) ) : #NEWLINE# #INDENT# flash ( 'This view requires the `all_datasource_access` permission' , 'danger' ) #NEWLINE# return redirect ( '/tablemodelview/list/' ) #NEWLINE# #UNINDENT# mydb = db . session . query ( models . Database ) . filter_by ( id = database_id ) . first ( ) #NEWLINE# engine = mydb . get_sqla_engine ( ) #NEWLINE# tables = engine . table_names ( ) #NEWLINE# table_name = request . args . get ( 'table_name' ) #NEWLINE# return self . render_template ( 'caravel/sql.html' , tables = tables , table_name = table_name , db = tables )