Skip to content

query macro with multiple databases #224

Closed

Description

@glademiller

I have a utility I am writing that will be connecting to multiple databases most MySQL and one Postgres and read data out and store the data in another format in another database. Looking at documentation and the source code it doesn't seem obvious if there is a way to support this scenario. The only possibility that comes to mind is to setup a workspace and somehow dynamically change the environment variable when building separate library packages. Would that be the only approach right now or am I missing something?

Thank you.

Activity

  1. mehcode commented on Apr 3, 2020

    @mehcode
    Contributor

    That is correct.

    See here: #121 (comment)

    We do want to support this. We were thinking a decent approach would be to generate a set of macros with a higher level macro.. e.g.,

    mod one { sqlx::database!(env!("ONE_DATABASE_URL")); }
    mod two { sqlx::database!(env!("TWO_DATABASE_URL")); }
    
    one::query!("...") // mysql://...
    two::query!("...") // postgres://...
  2. added
    duplicate
    on Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions