For a private db in AWS can I connect to it using ...
# prefect-community
For a private db in AWS can I connect to it using MysqlFetch in a function without
decorator ? I get
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '<|>' (timed out)")
every time. Any suggestions on how to approach in solving this?
I am using
as schedule and fetching the dates from a private db, which throws the 'can't connect to MySQL server' error.
it depends, which Prefect product are you using, and which version? what's your flow code?
Prefect cloud, version 1.2.2. Its a MySQLFetch call that is failing, and its outside the Flow. We need to call the MySQLFetch before to fetch dates from the db which will then be passed into schedule.
If i turn off the schedule then it works fine. Does MySQLFetch work outside a Flow?
no, all tasks must be called from the flow, although if you just want to test something out, you could manually trigger it outside of the flow by invoking the task's .run() method
Copy code
no but its not actually a task. Its a simple function which involves calling the db to fetch dates.
Though the db is private and we use jumphost or vpn to connect to it. So my question is does MySQLFetch work as a non-task method and still connect to the db?
how would you do it in Python? once you figure it out, you can run it in Prefect
No but there are other db calls also which work fine when run as a task. But this is for setting the schedule so it can't run as a task.
I think the jumphost part is solved as prefect is deployed in the same vpc as the db. And we have a working flow of this same code registered in cloud and is picked up by an agent running in the vm.
this is not the intended use case fir using schedules, I would encourage you to rethink the process and define the schedule either in your code or via UI rather than retrieving it from MySQL DB