labpack/databases/sql.py
def create(self, record_details): 
    
        '''
            a method to create a new record in the table 
        
            NOTE:   this class uses the id key as the primary key for all records
                    if record_details includes an id field that is an integer, float
                    or string, then it will be used as the primary key. if the id
                    field is missing, a unique 24 character url safe string will be 
                    created for the id field and included in the record_details
            
            NOTE:   record_details fields which do not exist in the record_model
                    or whose value do not match the requirements of the record_model
                    will throw an InputValidationError
            
            NOTE:   lists fields are pickled before they are saved to disk and
                    are not possible to search using sql query statements. it is
                    recommended that lists be stored instead as separate tables
                    
        :param record_details: dictionary with record fields 
        :return: string with primary key for record
        '''
        
    # validate inputs
        record_details = self.model.validate(record_details)
    
    # add fields to create request
        create_kwargs = {}
        for key, value in self.model.keyMap.items():
            record_key = key[1:]
            if record_key:
                if self.item_key.findall(record_key):
                    pass
                else:
                    if value['value_datatype'] in ('boolean', 'string', 'number'):
                        try:
                            results = self.model._walk(key, record_details)
                            create_kwargs[record_key] = results[0]
                        except:
                            pass
                    elif value['value_datatype'] == 'list':
                        try:
                            results = self.model._walk(key, record_details)
                            create_kwargs[record_key] = pickle.dumps(results[0])
                        except:
                            pass
    
    # add id field if missing     
        if not 'id' in create_kwargs.keys():
            create_kwargs['id'] = self.labID().id24
        elif isinstance(create_kwargs['id'], int):
            if not create_kwargs['id']:
                if not self.model.keyMap['.id']['declared_value']:
        # TODO increment record on sequence
                    pass
                    
    # insert record into table
        insert_statement = self.table.insert().values(**create_kwargs)
        self.session.execute(insert_statement)
        
        return create_kwargs['id']

            a method to create a new record in the table 
        
            NOTE:   this class uses the id key as the primary key for all records
                    if record_details includes an id field that is an integer, float
                    or string, then it will be used as the primary key. if the id
                    field is missing, a unique 24 character url safe string will be 
                    created for the id field and included in the record_details
            
            NOTE:   record_details fields which do not exist in the record_model
                    or whose value do not match the requirements of the record_model
                    will throw an InputValidationError
            
            NOTE:   lists fields are pickled before they are saved to disk and
                    are not possible to search using sql query statements. it is
                    recommended that lists be stored instead as separate tables
                    
        :param record_details: dictionary with record fields 
        :return: string with primary key for record
        
a method to create a new record in the table
NOTE:   this class uses the id key as the primary key for all records
if record_details includes an id field that is an integer, float
or string, then it will be used as the primary key. if the id
field is missing, a unique 24 character url safe string will be
created for the id field and included in the record_details

record_details fields which do not exist in the record_model
or whose value do not match the requirements of the record_model
will throw an InputValidationError

lists fields are pickled before they are saved to disk and
are not possible to search using sql query statements. it is
recommended that lists be stored instead as separate tables
a method to create a new record in the table NOTE : this class uses the id key as the primary key for all records if record_details includes an id field that is an integer float or string then it will be used as the primary key . if the id field is missing a unique 24 character url safe string will be created for the id field and included in the record_details record_details fields which do not exist in the record_model or whose value do not match the requirements of the record_model will throw an InputValidationError lists fields are pickled before they are saved to disk and are not possible to search using sql query statements . it is recommended that lists be stored instead as separate tables
def create(self, record_details): 
        record_details = self.model.validate(record_details)
        create_kwargs = {}
        for key, value in self.model.keyMap.items():
            record_key = key[1:]
            if record_key:
                if self.item_key.findall(record_key):
                    pass
                else:
                    if value['value_datatype'] in ('boolean', 'string', 'number'):
                        try:
                            results = self.model._walk(key, record_details)
                            create_kwargs[record_key] = results[0]
                        except:
                            pass
                    elif value['value_datatype'] == 'list':
                        try:
                            results = self.model._walk(key, record_details)
                            create_kwargs[record_key] = pickle.dumps(results[0])
                        except:
                            pass
        if not 'id' in create_kwargs.keys():
            create_kwargs['id'] = self.labID().id24
        elif isinstance(create_kwargs['id'], int):
            if not create_kwargs['id']:
                if not self.model.keyMap['.id']['declared_value']:
                    pass
        insert_statement = self.table.insert().values(**create_kwargs)
        self.session.execute(insert_statement)
        return create_kwargs['id']
def create ( self , record_details ) : record_details = self . model . validate ( record_details ) create_kwargs = { } for key , value in self . model . keyMap . items ( ) : record_key = key [ 1 : ] if record_key : if self . item_key . findall ( record_key ) : pass else : if value [ 'value_datatype' ] in ( 'boolean' , 'string' , 'number' ) : try : results = self . model . _walk ( key , record_details ) create_kwargs [ record_key ] = results [ 0 ] except : pass elif value [ 'value_datatype' ] == 'list' : try : results = self . model . _walk ( key , record_details ) create_kwargs [ record_key ] = pickle . dumps ( results [ 0 ] ) except : pass if not 'id' in create_kwargs . keys ( ) : create_kwargs [ 'id' ] = self . labID ( ) . id24 elif isinstance ( create_kwargs [ 'id' ] , int ) : if not create_kwargs [ 'id' ] : if not self . model . keyMap [ '.id' ] [ 'declared_value' ] : pass insert_statement = self . table . insert ( ) . values ( ** create_kwargs ) self . session . execute ( insert_statement ) return create_kwargs [ 'id' ]
a method to create a new record in the table
NOTE:   this class uses the id key as the primary key for all records
if record_details includes an id field that is an integer, float
or string, then it will be used as the primary key.
a method to create a new record in the table NOTE : this class uses the id key as the primary key for all records if record_details includes an id field that is an integer float or string then it will be used as the primary key .
'''
            a method to create a new record in the table 
        
            NOTE:   this class uses the id key as the primary key for all records
                    if record_details includes an id field that is an integer, float
                    or string, then it will be used as the primary key. if the id
                    field is missing, a unique 24 character url safe string will be 
                    created for the id field and included in the record_details
            
            NOTE:   record_details fields which do not exist in the record_model
                    or whose value do not match the requirements of the record_model
                    will throw an InputValidationError
            
            NOTE:   lists fields are pickled before they are saved to disk and
                    are not possible to search using sql query statements. it is
                    recommended that lists be stored instead as separate tables
                    
        :param record_details: dictionary with record fields 
        :return: string with primary key for record
        ''' # validate inputs # add fields to create request # add id field if missing      # TODO increment record on sequence # insert record into table
string with primary key for record
string with primary key for record
self
record_details
dictionary with record fields
dictionary with record fields