def pre_add(self, datasource): with db.session.no_autoflush: query = (db.session.query(models.DruidDatasource).filter( models.DruidDatasource.datasource_name == datasource.datasource_name, models.DruidDatasource.cluster_name == datasource.cluster.id)) if db.session.query(query.exists()).scalar(): raise Exception( get_datasource_exist_error_mgs(datasource.full_name))
def pre_add(self, datasource): number_of_existing_datasources = db.session.query( sqla.func.count('*')).filter( models.DruidDatasource.datasource_name == datasource.datasource_name, models.DruidDatasource.cluster_name == datasource.cluster.id).scalar() # table object is already added to the session if number_of_existing_datasources > 1: raise Exception( get_datasource_exist_error_mgs(datasource.full_name))
def pre_add(self, datasource): with db.session.no_autoflush: query = ( db.session.query(models.DruidDatasource) .filter(models.DruidDatasource.datasource_name == datasource.datasource_name, models.DruidDatasource.cluster_name == datasource.cluster.id) ) if db.session.query(query.exists()).scalar(): raise Exception(get_datasource_exist_error_mgs( datasource.full_name))
def pre_add(self, datasource): number_of_existing_datasources = db.session.query( sqla.func.count('*')).filter( models.DruidDatasource.datasource_name == datasource.datasource_name, models.DruidDatasource.cluster_name == datasource.cluster.id ).scalar() # table object is already added to the session if number_of_existing_datasources > 1: raise Exception(get_datasource_exist_error_mgs( datasource.full_name))
def pre_add(self, table): with db.session.no_autoflush: table_query = db.session.query(models.SqlaTable).filter( models.SqlaTable.table_name == table.table_name, models.SqlaTable.schema == table.schema, models.SqlaTable.database_id == table.database.id) if db.session.query(table_query.exists()).scalar(): raise Exception(get_datasource_exist_error_mgs( table.full_name)) # Fail before adding if the table can't be found if not table.database.has_table(table): raise Exception( _("Table [{}] could not be found, " "please double check your " "database connection, schema, and " "table name").format(table.name))
def pre_add(self, table): with db.session.no_autoflush: table_query = db.session.query(models.SqlaTable).filter( models.SqlaTable.table_name == table.table_name, models.SqlaTable.schema == table.schema, models.SqlaTable.database_id == table.database.id) if db.session.query(table_query.exists()).scalar(): raise Exception( get_datasource_exist_error_mgs(table.full_name)) # Fail before adding if the table can't be found if not table.database.has_table(table): raise Exception(_( 'Table [{}] could not be found, ' 'please double check your ' 'database connection, schema, and ' 'table name').format(table.name))
def pre_add(self, table): with db.session.no_autoflush: table_query = db.session.query(models.SqlaTable).filter( models.SqlaTable.table_name == table.table_name, models.SqlaTable.schema == table.schema, models.SqlaTable.database_id == table.database.id) if db.session.query(table_query.exists()).scalar(): raise Exception(get_datasource_exist_error_mgs( table.full_name)) # Fail before adding if the table can't be found try: table.get_sqla_table_object() except Exception: raise Exception( _('Table [{}] could not be found, ' 'please double check your ' 'database connection, schema, and ' 'table name').format(table.name))
def pre_add(self, table): number_of_existing_tables = db.session.query( sa.func.count('*')).filter( models.SqlaTable.table_name == table.table_name, models.SqlaTable.schema == table.schema, models.SqlaTable.database_id == table.database.id).scalar() # table object is already added to the session if number_of_existing_tables > 1: raise Exception(get_datasource_exist_error_mgs(table.full_name)) # Fail before adding if the table can't be found try: table.get_sqla_table_object() except Exception as e: logging.exception(e) raise Exception("Table [{}] could not be found, " "please double check your " "database connection, schema, and " "table name".format(table.name))
def pre_add(self, table): number_of_existing_tables = db.session.query( sa.func.count('*')).filter( models.SqlaTable.table_name == table.table_name, models.SqlaTable.schema == table.schema, models.SqlaTable.database_id == table.database.id ).scalar() # table object is already added to the session if number_of_existing_tables > 1: raise Exception(get_datasource_exist_error_mgs(table.full_name)) # Fail before adding if the table can't be found try: table.get_sqla_table_object() except Exception as e: logging.exception(e) raise Exception( "Table [{}] could not be found, " "please double check your " "database connection, schema, and " "table name".format(table.name))