COD database importer

COD database importer is used to import crystal structures from the Crystallography Open Database (COD) to AiiDA.


An instance of CodDbImporter is created as follows:

from import CodDbImporter

importer = CodDbImporter()

No additional parameters are required for standard queries on the main COD server.

How to do a query

A search is initiated by using the query() method, supplying statements using the keyword=value syntax:

results = importer.query(chemical_name="caffeine")

List of possible keywords can be listed using the method get_supported_keywords():


Values for most of the keywords can be encapsulated in a list. In that case the query will return entries that match any of the values (binary OR) from the list. Moreover, in the case of multiple keywords, entries that match all the conditions imposed by the keywords, will be returned (binary AND).


results = importer.query(chemical_name=["caffeine", "serotonin"], year=[2000, 2001])

is equivalent to the following SQL statement:

results = SELECT * FROM data WHERE
            ( chemical_name == "caffeine" OR chemical_name == "serotonin" ) AND
            ( year = 2000 OR year = 2001 )

A query returns an instance of CodSearchResults, which can be used in the same way as a list of CodEntry instances:

from __future__ import print_function


for entry in results:

Using data from CodEntry

CodEntry has a few methods (inherited from CifEntry) to access the contents of its instances: