Skip to content

Code Snippets

Roy Nieterau edited this page Jul 26, 2019 · 12 revisions

Interacting with Avalon database

The avalon database uses MongoDB. In Avalon's python api it exposes a thin wrapper around pymongo through avalon.io. Here are some example code snippets of how you could interact with the database.

Search asset by name with regex

Pymongo supports searching by regex and even allows to send a re.compile returned object as the value for a query directly.

import avalon.io as io
import re

# Compile a regex pattern
pattern = re.compile("character_.*")

# Search in avalon database by pattern
for asset in io.find({"name": pattern, "type": "asset"}):
    print(asset)
Clone this wiki locally