lapis icon indicating copy to clipboard operation
lapis copied to clipboard

Accessing multiple databases?

Open TangentFoxy opened this issue 6 years ago • 3 comments

I have a use case where I may want to access several databases within the same app. I know Lapis isn't designed to do this, is there a quick and dirty hacky way to do it?

TangentFoxy avatar Apr 24 '18 14:04 TangentFoxy

What kind of database is this? Is this postgres? Do you need to use models across both databases?

From a high level you minimally need to initialize a new connection to the database on the request, then run queries on it. For performance, you can use the ngx socket pool.

leafo avatar Apr 24 '18 22:04 leafo

Postgres. I don't strictly need to use models across both, but would prefer it.

I'm open to other solutions as well. My use case is unifying certain kinds of data from multiple applications running on their own domains on a main domain.

I'm considering just making an API for the data I need on each subdomain, and then having the main domain call that API to access the data it needs. Probably less efficient, but I'm guessing more practical.

TangentFoxy avatar Apr 24 '18 23:04 TangentFoxy

hi,@Guard13007, I change the lapis source to achieve the feature,here is my hack code: lapis.zip

It works for me

nneesshh avatar Jun 25 '18 01:06 nneesshh