https://prefect.io logo
Title
a

Adrien Besnard

04/17/2023, 10:15 AM
Hello! I just watched

this

and I was wondering: when is it better to use a Variable in place of a Block (like in this exemple, I now use a String Block to store the environment)?
1
c

Chris White

04/17/2023, 7:45 PM
Hi Adrien! This is a good question - you can think of variables sort of like environment variables; they are always strings (so don't have an inherent type other than String) and are typically single valued. Blocks, on the other hand, are generally typed with rich schemas. If you are using a string block you can continue to do so, but I highly recommend migrating that to a Variable instead - I think it will be less heavy than a block for you
a

Adrien Besnard

04/18/2023, 11:45 AM
Thanks a lot for your answer! I understand, but in the meantime, the process to setup blocks and variables are quite the same (you need to have a process which set them in order for the flows to be able to use them).
So the goal would have been to use blocks when you have to use 3rd party libraries (like dbt_prefect) and
variables
when you need to define variables related to your own environment?
💯 1
:upvote: 2
🙌 1
c

Chris White

04/18/2023, 5:16 PM
Yup I think that's a really good way of thinking about it!