from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from sfa.util.config import Config from sfa.util.sfalogging import logger from sqlalchemy import Column, Integer, String from sqlalchemy import Table, MetaData from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.dialects import postgresql from sqlalchemy.exc import NoSuchTableError #Dict holding the columns names of the table as keys #and their type, used for creation of the table slice_table = {'record_id_user': 'integer PRIMARY KEY references X ON DELETE \ CASCADE ON UPDATE CASCADE','oar_job_id':'integer DEFAULT -1', \ 'record_id_slice':'integer', 'slice_hrn':'text NOT NULL'} #Dict with all the specific senslab tables tablenames_dict = {'slab_xp': slice_table} SlabBase = declarative_base() class SenslabXP (SlabBase): """ SQL alchemy class to manipulate slice_senslab table in slab_sfa database. """ __tablename__ = 'slab_xp' slice_hrn = Column(String) job_id = Column(Integer, primary_key = True) end_time = Column(Integer, nullable = False) #oar_job_id = Column( Integer,default = -1) #node_list = Column(postgresql.ARRAY(String), nullable =True) def __init__ (self, slice_hrn =None, job_id=None, end_time=None): """ Defines a row of the slice_senslab table """ if slice_hrn: self.slice_hrn = slice_hrn if job_id : self.job_id = job_id if end_time: self.end_time = end_time def __repr__(self): """Prints the SQLAlchemy record to the format defined by the function. """ result = "