question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Is there a capability to connect to multiple databases

See original GitHub issue

Django provides a capability to define DATABASE_ROUTERS in settings.

  • It gives you a capability to define alias names in DATABASES for primary, replica*(1,2,3… so on).
  • you can customize the connection to read from replicas whereas write only to primary.
  • QuerySet object also provides assistance for this setting. https://docs.djangoproject.com/en/3.2/topics/db/multi-db/

Is there such a definition in piccolo to connect to multiple instances (or databases) and accordingly read and write queries can be split for efficiency? Did not find anything in the docs.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
dantownsendcommented, Apr 8, 2022

I’ve implemented a first version - will release it now. There’s future scope for adding routers etc like in Django, but hopefully this helps.

0reactions
dantownsendcommented, Apr 10, 2022

@satishdash Yeah, we can definitely build on top of it.

Something like this perhaps:

DB = PostgresEngine(
    config={...},
    extra_nodes={
        'read_slave_1': PostgresEngine(config={...})
    },
    routing={
        'get': {'some_table': 'read_slave_1'}
    }
)

Once an API design has been settled on, it shouldn’t be too hard to implement. If you have any ideas for an API let me know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

You're Using Too Many Databases. You Only Need One
Well, I'm here to tell you that you don't need to use multiple databases of your web apps. You only need one database:...
Read more >
Do you pull data from multiple databases?
You use multiple database for different use cases in our organisations and it's difficult to pull that information together in a coherent way....
Read more >
Optimal database combinations for literature searches in ...
Background. Within systematic reviews, when searching for relevant references, it is advisable to use multiple databases.
Read more >
Administration Guide for Connecting to Native Databases ...
The ability to connect to multiple databases through a single synchronization project simplifies the process of maintaining multiple database connections, as ...
Read more >
Benefits and detriments of multiple MySQL DB connections
There are no general positives or negatives to using multiple database connections in an application, it is always a case-specific issue.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found