diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..7f9da88 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,62 @@ +name: Target MSSQL tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: {} + +jobs: + linting: + runs-on: ubuntu-latest + strategy: + matrix: + # Only lint using the primary version used for dev + python-version: [3.9] + steps: + - uses: actions/checkout@v2 + - name: Set up Python '${{ matrix.python-version }}' + uses: actions/setup-python@v2 + with: + python-version: '${{ matrix.python-version }}' + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.1.14 + - name: Install dependencies + run: | + poetry install + - name: Run lint command from tox.ini + run: | + poetry run tox -e lint + pytest: + runs-on: ubuntu-latest + services: + mssql: + image: gvenzl/oracle-xe + env: + ORACLE_PASSWORD: P@55w0rd + ports: + - 1521:1521 + strategy: + matrix: + python-version: ["3.10", "3.11"] + steps: + - uses: actions/checkout@v2 + - name: Set up Python '${{ matrix.python-version }}' + uses: actions/setup-python@v2 + with: + python-version: '${{ matrix.python-version }}' + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: 1.1.11 + - name: Install dependencies + run: | + poetry install + - name: Test with pytest + run: | + poetry run pytest --capture=no diff --git a/meltano.yml b/meltano.yml index 1eb2d89..46048ea 100644 --- a/meltano.yml +++ b/meltano.yml @@ -26,6 +26,7 @@ plugins: - name: host - name: port - name: database + - name: schema - name: start_date value: '2010-01-01T00:00:00Z' - name: freeze_schema diff --git a/target_oracle/sinks.py b/target_oracle/sinks.py index d451a53..dd228e5 100644 --- a/target_oracle/sinks.py +++ b/target_oracle/sinks.py @@ -42,6 +42,7 @@ def get_sqlalchemy_url(self, config: dict) -> str: host=config["host"], port=config["port"], database=config["database"], + schema = config["schema"] or config["user"] ) return connection_url diff --git a/target_oracle/target.py b/target_oracle/target.py index 244d7e4..141cd6b 100644 --- a/target_oracle/target.py +++ b/target_oracle/target.py @@ -65,6 +65,12 @@ class TargetOracle(SQLTarget): th.BooleanType, description="Do not alter types of existing columns", default=False + ), + th.Property( + "schema", + th.StringType, + description="Target database schema for the data", + default=None ) ).to_dict() diff --git a/target_oracle/tests/test_core.py b/target_oracle/tests/test_core.py index f4c35f9..7d99ed8 100644 --- a/target_oracle/tests/test_core.py +++ b/target_oracle/tests/test_core.py @@ -30,7 +30,6 @@ def oracle_config(): } oracle_config_dict = { - "schema": "SYSTEM", "user": "SYSTEM", "password": "P@55w0rd", "host": "localhost", @@ -72,6 +71,7 @@ def get_engine(): host=config["host"], port=config["port"], database=config["database"], + schema = config["schema"] or config["user"] ) engine = create_engine(connection_url)