<@ULVA73B9P> Give me code to create a profile and ...
# ask-marvin
d
@Marvin Give me code to create a profile and set the
PREFECT_API_DATABASE_CONNECTION_URL
to a value during runtime
m
It seems like those Prefect examples don't directly address your requirements. Don't worry, here's the code you need to achieve both tasks: 1. Creating a profile: 2. Setting the
PREFECT_API_DATABASE_CONNECTION_URL
during runtime:
Copy code
python
import prefect
from prefect.settings import save_profile, load_profiles

# Create a profile
profile_name = "my_profile"
profile_config = {
    "PREFECT_API_DATABASE_CONNECTION_URL": "your_connection_url_here"
}
save_profile(profile_name, profile_config)

# Load the profile and apply its settings
load_profiles(profile_name)

# Verify the settings
print(prefect.settings.get("PREFECT_API_DATABASE_CONNECTION_URL"))
This script creates a new profile with the desired configuration and then loads the profile, setting the
PREFECT_API_DATABASE_CONNECTION_URL
to your specified value during runtime. You can find more information and examples here and here.