Find Keyword#
Help#
- metacatalog.api.find_keyword(return_iterator: typing_extensions.Literal[False] = False) List['Keyword'] #
- metacatalog.api.find_keyword(return_iterator: typing_extensions.Literal[True] = False) Query
Return one or many keyword entries from the database on exact matches.
- Parameters:
session (sqlalchemy.Session) – SQLAlchemy session connected to the database.
id (integer) – Database unique ID of the requested record. Will return only one record.
uuid (str) –
New in version 0.1.13.
Find by version 4 UUID. If uuid is given, all other options will be ignored.
value (str) – Value of the requested keyword(s). Multiple record return is possible.
full_path (str) –
New in version 0.8.4.
Full path of the requested keyword.
thesaurus_name (str) –
New in version 0.1.10.
The name of the thesaurus, the keyword originates from. At the current stage, only ‘GCMD’ science keywords are implemented.
return_iterator (bool) – If True, an iterator returning the requested objects instead of the objects themselves is returned.
- Returns:
records – List of matched Keyword instance.
- Return type:
list of metacatalog.Keyword
Example#
[1]:
from metacatalog import api
session = api.connect_database()
---------------------------------------------------------------------------
CommandError Traceback (most recent call last)
<ipython-input-1-f0273587aace> in <module>
1 from metacatalog import api
2
----> 3 session = api.connect_database()
~/Dropbox/python/metacatalog/metacatalog/api/db.py in connect_database(*args, **kwargs)
55 """
56 # get session
---> 57 session = get_session(*args, **kwargs)
58
59 return session
~/Dropbox/python/metacatalog/metacatalog/db/session.py in get_session(*args, **kwargs)
98
99 # else build a new engine
--> 100 engine = get_engine(*args, **kwargs)
101
102 # create the Session class
~/Dropbox/python/metacatalog/metacatalog/db/session.py in get_engine(*args, **kwargs)
81 # check alembic version
82 try:
---> 83 check_database_version(engine=engine)
84 except RuntimeError as e:
85 # no missmatch allowed
~/Dropbox/python/metacatalog/metacatalog/db/migration.py in check_database_version(engine)
31 # get the alembic config file
32 config = Config(os.path.join(BASEPATH, '..', 'alembic.ini'))
---> 33 script_ = script.ScriptDirectory.from_config(config)
34
35 # connect to database
~/miniconda3/envs/py37/lib/python3.7/site-packages/alembic-1.4.2-py3.7.egg/alembic/script/base.py in from_config(cls, config)
147 version_locations=version_locations,
148 timezone=config.get_main_option("timezone"),
--> 149 hook_config=config.get_section("post_write_hooks", {}),
150 )
151
~/miniconda3/envs/py37/lib/python3.7/site-packages/alembic-1.4.2-py3.7.egg/alembic/script/base.py in __init__(self, dir, file_template, truncate_slug_length, version_locations, sourceless, output_encoding, timezone, hook_config)
68 "Path doesn't exist: %r. Please use "
69 "the 'init' command to create a new "
---> 70 "scripts folder." % os.path.abspath(dir)
71 )
72
CommandError: Path doesn't exist: '/home/mirko/Dropbox/python/metacatalog/docs/source/api/alembic'. Please use the 'init' command to create a new scripts folder.
[6]:
for kw in api.find_keyword(session, value='*TEMPERATURE*'):
print(kw.full_path)