import os
import sqlite3
from sqlite3 import Connection


class SqliteRepositoryFactory(object):

    def __init__(
        self,
        database_dir: str,
    ) -> None:

        self.database_dir = database_dir

    def create_connection(
        self,
        db_name: str,
    ) -> Connection:

        db_path = os.path.abspath(os.path.join(self.database_dir, db_name))
        conn_string = f"file:///{db_path}.db"
        return sqlite3.connect(database=conn_string, uri=True)
