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

Add command for QueryService Repository #61

Closed
andrea-mucci opened this issue Feb 6, 2022 · 0 comments
Closed

Add command for QueryService Repository #61

andrea-mucci opened this issue Feb 6, 2022 · 0 comments
Assignees
Labels
cli enhancement New feature or request

Comments

@andrea-mucci
Copy link
Contributor

The minos cli must have the following command

minos queryservice set repository

this command must ask:

  • which database? ( at the moment we support sqlalchemy as ORM, so we have to propose mysql/postgresql/sqlite )
  • database host
  • database port
  • database name

the cli would create the following files

queries/models.py

from sqlalchemy.orm import declarative_base

Base = declarative_base()

queries/repository.py

from minos.common import MinosSetup, MinosConfig
from sqlalchemy import create_engine
from src.queries.models import Base

class QueryServiceRepository(MinosSetup):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.engine = create_engine({{ THE URL DATABASE }})

    async def _setup(self) -> None:
        Base.metadata.create_all(self.engine)

    @classmethod
    def _from_config(cls, *args, config: MinosConfig, **kwargs) -> ProductQueryRepository:
        return cls(*args, **(config.query_repository._asdict()) | kwargs)

the CLI must update the config.yml as well

...

query:
  database: database_choosen_by_the_dev_db
  user: postgres
  password: ""
  host: localhost
  port: 5432

And must modify the plkaybooks/create-databse.yaml adding the following information

- name: Create Query Database
  import_playbook: ../../../external/postgres/playbooks/create-database.yaml
  vars:
    db_name: database_choosen_by_the_dev_db
@andrea-mucci andrea-mucci added enhancement New feature or request cli labels Feb 6, 2022
albamig added a commit that referenced this issue Feb 10, 2022
albamig added a commit that referenced this issue Feb 10, 2022
@albamig albamig closed this as completed Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants