*import the astorb orbital elements to database*

        **Key Arguments:**
            - ``astorbDictList`` -- the astorb database parsed as a list of dictionaries

        **Return:**
            - None
513541
def _import_astorb_to_database(
            self,
            astorbDictList):
        
        self.log.info('starting the ``_import_astorb_to_database`` method')

        print "Refreshing the orbital elements database table"

        dbSettings = self.settings["database settings"]["atlasMovers"]

        insert_list_of_dictionaries_into_database_tables(
            dbConn=self.atlasMoversDBConn,
            log=self.log,
            dictList=astorbDictList,
            dbTableName="orbital_elements",
            uniqueKeyList=["name"],
            dateModified=True,
            batchSize=10000,
            replace=True,
            dbSettings=dbSettings
        )

        print "Finished refreshing the orbital elements database table"

        self.log.info('completed the ``_import_astorb_to_database`` method')
        return None
220519
def _dict_to_list_ids(objects):
    '''
    
    '''
    list_with_ids = []
    for key, value in six.iteritems(objects):
        element = {'id': key}
        element.update(value)
        list_with_ids.append(element)
    return list_with_ids
333409
def fromdict(self, src_dict, method='set'):
        
        if method == 'set':
            _method = self.set_method
        else:
            _method = self.add_method
        if hasattr(src_dict, 'iteritems'):
            for (key, val) in src_dict.iteritems():
                _method(self, key, len(key), val)
                if self.k:
                    self._update(key, val)
        else:
            for (key, val) in src_dict.items():
                _method(self, key, len(key), val)
                if self.k:
                    self._update(key, val)
106167
def db_to_dict(db):
    
    return {
            A.database.HOST: db.hostname,
            A.database.PORT: db.port,
            }
147806
def import_(self, data):
        """"""
        return self.__import(json.loads(data, **self.kwargs))
1077482
def as_dict(self):
        

        d = {"@module": self.__class__.__module__,
             "@class": self.__class__.__name__,
             "molecule": self.molecule.as_dict(),
             "graphs": json_graph.adjacency_data(self.graph)}

        return d
1225743
def _add_matched_objects_to_database(
            self,
            matchedObjects):
        
        self.log.info(
            'starting the ``_add_matched_objects_to_database`` method')

        print "Adding the matched sources to the `pyephem_positions` database table"

        allMatches = []
        for m in matchedObjects:
            allMatches += m

        dbSettings = self.settings["database settings"]["atlasMovers"]

        insert_list_of_dictionaries_into_database_tables(
            dbConn=self.atlasMoversDBConn,
            log=self.log,
            dictList=allMatches,
            dbTableName="pyephem_positions",
            uniqueKeyList=["expname", "object_name"],
            dateModified=True,
            batchSize=10000,
            replace=True,
            dbSettings=dbSettings
        )

        self.log.info(
            'completed the ``_add_matched_objects_to_database`` method')
        return None
383863
def dict(self):
        
        from collections import OrderedDict

        d = OrderedDict(
            [(p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in ('data',)])

        if 'list' in self.data:
            d['bundle_count'] = len(self.data['list'])
        else:
            d['bundle_count'] = None

        if self.data:
            for k, v in self.data.items():
                d[k] = v

        return d
1048034
def meta_to_indexes(meta, table_name=None, model_name=None):
    
    indexes, pk_field = {}, None

    indexes = []
    for meta_model_name, model_meta in meta.iteritems():
        if (table_name or model_name) and not (table_name == model_meta['Meta'].get('db_table', '') or model_name == meta_model_name):
            continue
        field_name, field_infodict, score = find_index(model_meta)
        indexes.append(('%s.%s' % (meta_model_name, field_name), field_infodict, score))
    return indexes
593404
def as_dict(self):
        
        d = {"@module": self.__class__.__module__,
             "@class": self.__class__.__name__,
             "name": self.name, "options": self.options}
        if len(self.subkeys) > 0:
            subkeys = []
            for subkey in self.subkeys:
                subkeys.append(subkey.as_dict())
            d.update({"subkeys": subkeys})
        return d
961611
def persist_trie_data_dict(self, trie_data_dict: Dict[Hash32, bytes]) -> None:
        
        with self.db.atomic_batch() as db:
            for key, value in trie_data_dict.items():
                db[key] = value
856327
def fetchall_as_dictlist(self, sql: str, *args) -> List[Dict[str, Any]]:
        """"""
        self.ensure_db_open()
        cursor = self.db.cursor()
        self.db_exec_with_cursor(cursor, sql, *args)
        try:
            rows = cursor.fetchall()
            fieldnames = [i[0] for i in cursor.description]
            dictlist = []
            for r in rows:
                dictlist.append(dict(zip(fieldnames, r)))
            return dictlist
        except:  # nopep8
            log.exception("fetchall_as_dictlist: SQL was: " + sql)
            raise
1217782
def import_from_dicts(data, samples=None, *args, **kwargs):
    

    data = iter(data)

    cached_rows, headers = [], []
    for index, row in enumerate(data, start=1):
        cached_rows.append(row)

        for key in row.keys():
            if key not in headers:
                headers.append(key)

        if samples and index == samples:
            break

    data_rows = (
        [row.get(header, None) for header in headers]
        for row in chain(cached_rows, data)
    )

    kwargs["samples"] = samples
    meta = {"imported_from": "dicts"}
    return create_table(chain([headers], data_rows), meta=meta, *args, **kwargs)
818471
def as_dict(self):
        
        ce_list_dict = [{str(cn): [ce.as_dict() if ce is not None else None for ce in ce_dict[cn]]
                         for cn in ce_dict} if ce_dict is not None else None for ce_dict in self.ce_list]
        nbs_sets_dict = [{str(cn): [nb_set.as_dict() for nb_set in nb_sets]
                          for cn, nb_sets in site_nbs_sets.items()}
                         if site_nbs_sets is not None else None
                         for site_nbs_sets in self.neighbors_sets]
        info_dict = {key: val for key, val in self.info.items() if key not in ['sites_info']}
        info_dict['sites_info'] = [{'nb_sets_info': {str(cn): {str(inb_set): nb_set_info
                                                               for inb_set, nb_set_info in cn_sets.items()}
                                                     for cn, cn_sets in site_info['nb_sets_info'].items()},
                                    'time': site_info['time']} if 'nb_sets_info' in site_info else {}
                                   for site_info in self.info['sites_info']]

        return {"@module": self.__class__.__module__,
                "@class": self.__class__.__name__,
                "voronoi": self.voronoi.as_dict(),
                "valences": self.valences,
                "sites_map": self.sites_map,
                "equivalent_sites": [[ps.as_dict() for ps in psl] for psl in self.equivalent_sites],
                "ce_list": ce_list_dict,
                "structure": self.structure.as_dict(),
                "neighbors_sets": nbs_sets_dict,
                "info": info_dict}
1023713
def from_dict(cls, database, key, data, clear=False):
        
        hsh = cls(database, key)
        if clear:
            hsh.clear()
        hsh.update(data)
        return hsh
1019156
def from_dict(cls, d):
        
        tdos = PhononDos.from_dict(d)
        struct = Structure.from_dict(d["structure"])
        pdoss = {}
        for at, pdos in zip(struct, d["pdos"]):
            pdoss[at] = pdos

        return cls(struct, tdos, pdoss)
840937
def import_from_dict(cls, session, dict_rep, parent=None,
                         recursive=True, sync=[]):
        """"""
        parent_refs = cls._parent_foreign_key_mappings()
        export_fields = set(cls.export_fields) | set(parent_refs.keys())
        new_children = {c: dict_rep.get(c) for c in cls.export_children
                        if c in dict_rep}
        unique_constrains = cls._unique_constrains()

        filters = []  # Using these filters to check if obj already exists

        # Remove fields that should not get imported
        for k in list(dict_rep):
            if k not in export_fields:
                del dict_rep[k]

        if not parent:
            if cls.export_parent:
                for p in parent_refs.keys():
                    if p not in dict_rep:
                        raise RuntimeError(
                            '{0}: Missing field {1}'.format(cls.__name__, p))
        else:
            # Set foreign keys to parent obj
            for k, v in parent_refs.items():
                dict_rep[k] = getattr(parent, v)

        # Add filter for parent obj
        filters.extend([getattr(cls, k) == dict_rep.get(k)
                        for k in parent_refs.keys()])

        # Add filter for unique constraints
        ucs = [and_(*[getattr(cls, k) == dict_rep.get(k)
               for k in cs if dict_rep.get(k) is not None])
               for cs in unique_constrains]
        filters.append(or_(*ucs))

        # Check if object already exists in DB, break if more than one is found
        try:
            obj_query = session.query(cls).filter(and_(*filters))
            obj = obj_query.one_or_none()
        except MultipleResultsFound as e:
            logging.error('Error importing %s \n %s \n %s', cls.__name__,
                          str(obj_query),
                          yaml.safe_dump(dict_rep))
            raise e

        if not obj:
            is_new_obj = True
            # Create new DB object
            obj = cls(**dict_rep)
            logging.info('Importing new %s %s', obj.__tablename__, str(obj))
            if cls.export_parent and parent:
                setattr(obj, cls.export_parent, parent)
            session.add(obj)
        else:
            is_new_obj = False
            logging.info('Updating %s %s', obj.__tablename__, str(obj))
            # Update columns
            for k, v in dict_rep.items():
                setattr(obj, k, v)

        # Recursively create children
        if recursive:
            for c in cls.export_children:
                child_class = cls.__mapper__.relationships[c].argument.class_
                added = []
                for c_obj in new_children.get(c, []):
                    added.append(child_class.import_from_dict(session=session,
                                                              dict_rep=c_obj,
                                                              parent=obj,
                                                              sync=sync))
                # If children should get synced, delete the ones that did not
                # get updated.
                if c in sync and not is_new_obj:
                    back_refs = child_class._parent_foreign_key_mappings()
                    delete_filters = [getattr(child_class, k) ==
                                      getattr(obj, back_refs.get(k))
                                      for k in back_refs.keys()]
                    to_delete = set(session.query(child_class).filter(
                        and_(*delete_filters))).difference(set(added))
                    for o in to_delete:
                        logging.info('Deleting %s %s', c, str(obj))
                        session.delete(o)

        return obj