Skip to content

How To have multiple database connections #166

Answered by jondot
ace3 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes I think @ace3 is correct, since this is "just" a second connection, we can use it only in "routing time", meaning routers get access to it which means Loco does not manage it (no migrations, reset, etc.), it just uses it as a live DB.

Lets start a story, thinking out loud

The solution should be something very similar to this:

  1. Adding as an extension: https://github.com/loco-rs/loco/blob/master/examples/llm-candle-inference/src/app.rs#L41-L42 (instead of model, a pg pool). All the "preparation code" for getting a pg db URL, etc. can be done just before this step.
  2. Consuming it in a router, like this: https://github.com/loco-rs/loco/blob/master/examples/llm-candle-inference/src/controlle…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@jondot
Comment options

@kaplanelad
Comment options

@ace3
Comment options

@jondot
Comment options

Answer selected by ace3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants