Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HELP: How to change database name in every invocation? #60

Open
dashmug opened this issue Nov 25, 2019 · 1 comment
Open

HELP: How to change database name in every invocation? #60

dashmug opened this issue Nov 25, 2019 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers question Further information is requested

Comments

@dashmug
Copy link

dashmug commented Nov 25, 2019

I work on a multi-tenant application with each tenant having their own database living on the same database instance.

So, currently in my Lambdas, I connect AND disconnect during the Lambda invocation as I need the request information to determine which database to connect to. The host, port, username, password are all constants. Only the database name changes between invocations. This setup currently works easily with the mysql library. However, it is not optimal as I cannot reuse connections.

Will changeUser help me in this case?

Is it possible to connect to the database instance during cold-start but switch database during invocation?

Does changeUser disconnect from the instance?

Thank you for the help.

@jeremydaly
Copy link
Owner

Hi @dashmug,

changeUser has not been implemented in the library as of yet, but if you need to access data on the same instance (and the user has access to both databases), you can preface your queries with the database name, e.g.:

SELECT * FROM myDatabase.myTable WHERE x = 1;

The changeUser command doesn't disconnect the connection, but as I said, it isn't implemented in the library yet.

  • Jeremy

@jeremydaly jeremydaly added enhancement New feature or request question Further information is requested labels Nov 25, 2019
@naorpeled naorpeled added the good first issue Good for newcomers label Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants