It's possible to trigger an action inside a custon database script as Login (MySQL)?

Hey there! I’m on an project using MySQL and we’ve to do lazy migration with the custom database scripts provided as Login or GetUser.
To access my legacy DB, I’m was thinking of creating an action to go find the data of the user, because I my connection must be done through an api endpoint and not directly to the legacy db.
My question is:
Is it possible to integrate a triggered action inside a Login script? If it’s not, how can I manage the connection to the legacy DB?