a

    Abhishek Mitra

    2 months ago
    For a private db in AWS can I connect to it using MysqlFetch in a function without
    @task
    decorator ? I get
    pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '<http://xyz-mysql8-cluster.cluster-fa43asdfd.us-west-2.rds.amazonaws.com|xyz-mysql8-cluster.cluster-fa43asdfd.us-west-2.rds.amazonaws.com>' (timed out)")
    every time. Any suggestions on how to approach in solving this?
    I am using
    DatesClock
    as schedule and fetching the dates from a private db, which throws the 'can't connect to MySQL server' error.
    Anna Geller

    Anna Geller

    2 months ago
    it depends, which Prefect product are you using, and which version? what's your flow code?
    a

    Abhishek Mitra

    2 months ago
    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?
    Anna Geller

    Anna Geller

    2 months ago
    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
    MySQLFetch(init_args).run(runtime_args)
    a

    Abhishek Mitra

    2 months ago
    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?
    Anna Geller

    Anna Geller

    2 months ago
    how would you do it in Python? once you figure it out, you can run it in Prefect
    a

    Abhishek Mitra

    2 months ago
    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.
    Anna Geller

    Anna Geller

    2 months ago
    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