Skip to content

ormar - multiple DB #154

Answered by collerek
avico78 asked this question in Q&A
Apr 19, 2021 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

I'm not sure if I follow, but if you ask what i think you ask you can:

either rename the models to reflect the module:

class TestA(ormar.Model): # different name
    class Meta(BaseMetaDB_a):
        tablename: str = "test"
    id: int = ormar.Integer(primary_key=True)
    some_key: int = ormar.Integer()

ormar module db_b

class TestB(ormar.Model): # different name
    class Meta(BaseMetaDB_b):
        tablename: str = "test"
    id: int = ormar.Integer(primary_key=True)
    some_key: int = ormar.Integer()

other app module:

from module_a import TestA
from module_b import TestB

# the names differ
await TestA().save()
await TestB().save()

or if you don't wont to rename the classes simply im…

Replies: 1 comment 4 replies

Comment options

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

@collerek
Comment options

@avico78
Comment options

@collerek
Comment options

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