SQL controller

This is the base sql class. It is mostly used per animal, so the init function needs an animal passed to the constructor It also needs for the animal, histology and scan run tables to be filled out for each animal to use

class library.controller.sql_controller.SqlController(animal, rescan_number=0)

Bases: library.controller.annotation_session_controller.AnnotationSessionController, library.controller.animal_controller.AnimalController, library.controller.elastix_controller.ElastixController, library.controller.histology_controller.HistologyController, library.controller.scan_run_controller.ScanRunController, library.controller.sections_controller.SectionsController, library.controller.slide_tif_controller.SlideCZIToTifController

This is the base controller class for all things SQL. Each parent class of SqlController would correspond to one table in the database, and include all the methods to interact with that table

add_row(data)

adding a row to a table

Parameters

data – (data to be added ): instance of sqalchemy ORMs

delete_row(search_dictionary, model)

Deletes one row of any table

Parameters
  • search_dictionary – (dict): search field and value

  • model – (sqalchemy ORM class): sqalchemy ORM

get_resolution(animal)

Returns the resolution for an animal

Parameters

animal – string primary key

Return numpy array

of the resolutions

get_row(search_dictionary, model)

look for a specific row in the database and return the result

Parameters
  • search_dictionary – (dict): field and value of the search

  • model – (sqalchemy ORM): the sqalchemy ORM in question

Returns

sql alchemy query

query_table(search_dictionary, model)

query a sql table and return all the results fitting the search criterias

Parameters
  • search_dictionary – (dict): search field and value

  • model – (sqalchemy ORM class): sqalchemy ORM

returns list: the query result in a list of ORM objects

row_exists(search_dictionary, model)

check if a specific row exist in a table

Parameters
  • search_dictionary – (dict): field and value for the search

  • model – (sqalchemy ORM): sqalchemy ORM

Return boolean

whether the row exists

update_row(row)

update one row of a database

Parameters

row – a row of a database table.