Skip to content

Check if project already exist via Python #5155

Answered by zanieb
BKuasney asked this question in General
Discussion options

You must be logged in to vote
from prefect import Client
from prefect.utilities.graphql import with_args

project_name = "asfsafasfa"

query = {
    "query": {
        with_args("project", {"where": {"name": {"_eq": project_name}}}): {"id": True}
    }
}

client = Client()
result = client.graphql(query)

if result.data.project:
    print("Exists!")
else:
    print("Does not exist!")

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@BKuasney
Comment options

Answer selected by BKuasney
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants