fluidattacks_connection_manager 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fluidattacks_connection_manager-1.0.0/.envrc +2 -0
- fluidattacks_connection_manager-1.0.0/PKG-INFO +11 -0
- fluidattacks_connection_manager-1.0.0/build/default.nix +16 -0
- fluidattacks_connection_manager-1.0.0/build/deps/arch_lint.nix +17 -0
- fluidattacks_connection_manager-1.0.0/build/deps/default.nix +32 -0
- fluidattacks_connection_manager-1.0.0/build/deps/fa_purity.nix +19 -0
- fluidattacks_connection_manager-1.0.0/build/deps/snowflake_client.nix +40 -0
- fluidattacks_connection_manager-1.0.0/build/filter.nix +11 -0
- fluidattacks_connection_manager-1.0.0/flake.lock +196 -0
- fluidattacks_connection_manager-1.0.0/flake.nix +28 -0
- fluidattacks_connection_manager-1.0.0/fluidattacks_connection_manager/__init__.py +31 -0
- fluidattacks_connection_manager-1.0.0/fluidattacks_connection_manager/_common.py +178 -0
- fluidattacks_connection_manager-1.0.0/fluidattacks_connection_manager/_connection/__init__.py +160 -0
- fluidattacks_connection_manager-1.0.0/fluidattacks_connection_manager/_connection/_core.py +55 -0
- fluidattacks_connection_manager-1.0.0/fluidattacks_connection_manager/_connection/_setup.py +85 -0
- fluidattacks_connection_manager-1.0.0/fluidattacks_connection_manager/_utils.py +202 -0
- fluidattacks_connection_manager-1.0.0/fluidattacks_connection_manager/py.typed +0 -0
- fluidattacks_connection_manager-1.0.0/mypy.ini +30 -0
- fluidattacks_connection_manager-1.0.0/pyproject.toml +17 -0
- fluidattacks_connection_manager-1.0.0/ruff.toml +29 -0
- fluidattacks_connection_manager-1.0.0/tests/__init__.py +0 -0
- fluidattacks_connection_manager-1.0.0/tests/arch/__init__.py +0 -0
- fluidattacks_connection_manager-1.0.0/tests/arch/arch.py +46 -0
- fluidattacks_connection_manager-1.0.0/tests/arch/test_arch.py +43 -0
- fluidattacks_connection_manager-1.0.0/tests/py.typed +0 -0
- fluidattacks_connection_manager-1.0.0/uv.lock +204 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fluidattacks_connection_manager
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Common connection utils
|
|
5
|
+
Author-email: Product Team <development@fluidattacks.com>
|
|
6
|
+
Requires-Python: >=3.11
|
|
7
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
8
|
+
Requires-Dist: fa-purity >=2.1.0, <3.0.0
|
|
9
|
+
Requires-Dist: fluidattacks-etl-utils >=1.0.0, <2.0.0
|
|
10
|
+
Requires-Dist: redshift-client >=8.0.1, <9.0.0
|
|
11
|
+
Requires-Dist: snowflake-client >=3.0.2, <4.0.0
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{ nixpkgs, pynix, src, local_lib }:
|
|
2
|
+
let
|
|
3
|
+
deps = import ./deps { inherit nixpkgs pynix local_lib; };
|
|
4
|
+
requirements = python_pkgs: {
|
|
5
|
+
runtime_deps = with python_pkgs; [ etl-utils fa-purity snowflake-client ];
|
|
6
|
+
build_deps = with python_pkgs; [ flit-core ];
|
|
7
|
+
test_deps = with python_pkgs; [ arch-lint mypy pytest pytest-cov ruff ];
|
|
8
|
+
};
|
|
9
|
+
in {
|
|
10
|
+
inherit src requirements;
|
|
11
|
+
root_path = "observes/common/connection-manager";
|
|
12
|
+
module_name = "fluidattacks_connection_manager";
|
|
13
|
+
pypi_token_var = "CONNECTION_MANAGER_TOKEN";
|
|
14
|
+
defaultDeps = deps.python_pkgs;
|
|
15
|
+
override = b: b;
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{ nixpkgs, pynix, python_pkgs }:
|
|
2
|
+
let
|
|
3
|
+
commit = "43aa33ef4cfa12c37148f4653dd89233c585c368"; # v4.0.4
|
|
4
|
+
sha256 = "06r2xfj50rn9m87i3vwa9bilhnrz3njhmfd992vzp4a5x937rfq2";
|
|
5
|
+
bundle = let
|
|
6
|
+
src = builtins.fetchTarball {
|
|
7
|
+
inherit sha256;
|
|
8
|
+
url =
|
|
9
|
+
"https://gitlab.com/dmurciaatfluid/arch_lint/-/archive/${commit}/arch_lint-${commit}.tar";
|
|
10
|
+
};
|
|
11
|
+
in import "${src}/build" {
|
|
12
|
+
inherit src;
|
|
13
|
+
inherit nixpkgs pynix;
|
|
14
|
+
};
|
|
15
|
+
extended_python_pkgs = python_pkgs // { inherit (bundle.deps) grimp; };
|
|
16
|
+
in bundle.builders.pkgBuilder
|
|
17
|
+
(bundle.builders.requirements extended_python_pkgs)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{ nixpkgs, pynix, local_lib }:
|
|
2
|
+
let
|
|
3
|
+
python_overlay = final: prev: {
|
|
4
|
+
arch-lint = import ./arch_lint.nix {
|
|
5
|
+
inherit nixpkgs pynix;
|
|
6
|
+
python_pkgs = prev;
|
|
7
|
+
};
|
|
8
|
+
fa-purity = import ./fa_purity.nix {
|
|
9
|
+
inherit nixpkgs pynix;
|
|
10
|
+
python_pkgs = final;
|
|
11
|
+
};
|
|
12
|
+
etl-utils = local_lib.etl_utils_bundle.builders.pkgBuilder
|
|
13
|
+
(local_lib.etl_utils_bundle.builders.requirements {
|
|
14
|
+
inherit nixpkgs;
|
|
15
|
+
python_pkgs = final;
|
|
16
|
+
});
|
|
17
|
+
s3transfer = prev.s3transfer.overridePythonAttrs (oldAttrs: {
|
|
18
|
+
preCheck = nixpkgs.lib.optionalString nixpkgs.stdenv.isDarwin ''
|
|
19
|
+
export TMPDIR="/tmp"
|
|
20
|
+
'';
|
|
21
|
+
});
|
|
22
|
+
snowflake-client = let
|
|
23
|
+
bundle =
|
|
24
|
+
import ./snowflake_client.nix { inherit nixpkgs pynix python_pkgs; };
|
|
25
|
+
in bundle.pkg;
|
|
26
|
+
};
|
|
27
|
+
python = pynix.lib.python.override {
|
|
28
|
+
packageOverrides = python_overlay;
|
|
29
|
+
self = python;
|
|
30
|
+
};
|
|
31
|
+
python_pkgs = python.pkgs;
|
|
32
|
+
in { inherit python_pkgs; }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{ nixpkgs, pynix, python_pkgs }:
|
|
2
|
+
let
|
|
3
|
+
commit = "e669114103b334e532aec34dc5b2ec06dfd24247"; # v2.5.0+1
|
|
4
|
+
sha256 = "1x0ipsklpsxyrzy8j6agkqppj4n2x67kaz7zsi3mkycan9z9z3f8";
|
|
5
|
+
bundle = let
|
|
6
|
+
src = builtins.fetchTarball {
|
|
7
|
+
inherit sha256;
|
|
8
|
+
url =
|
|
9
|
+
"https://gitlab.com/dmurciaatfluid/purity/-/archive/${commit}/purity-${commit}.tar";
|
|
10
|
+
};
|
|
11
|
+
in import "${src}/build" {
|
|
12
|
+
inherit src;
|
|
13
|
+
inherit nixpkgs pynix;
|
|
14
|
+
};
|
|
15
|
+
extended_python_pkgs = python_pkgs // {
|
|
16
|
+
inherit (bundle.deps) types-simplejson;
|
|
17
|
+
};
|
|
18
|
+
in bundle.builders.pkgBuilder
|
|
19
|
+
(bundle.builders.requirements extended_python_pkgs)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{ nixpkgs, pynix, python_pkgs }:
|
|
2
|
+
let
|
|
3
|
+
commit = "b516409c11a25af8acf933dee055f9784c994b2f"; # v3.2.3
|
|
4
|
+
sha256 = "0jv5h7wbcn437l3rf41qc7sdg31q900lhn2pcjix00s181psmihq";
|
|
5
|
+
bundle = let
|
|
6
|
+
src = builtins.fetchTarball {
|
|
7
|
+
inherit sha256;
|
|
8
|
+
url =
|
|
9
|
+
"https://gitlab.com/dmurciaatfluid/snowflake_client/-/archive/${commit}/snowflake_client-${commit}.tar";
|
|
10
|
+
};
|
|
11
|
+
in import "${src}/build" {
|
|
12
|
+
inherit src;
|
|
13
|
+
inherit nixpkgs pynix;
|
|
14
|
+
};
|
|
15
|
+
extended_python_pkgs = python_pkgs // {
|
|
16
|
+
inherit (bundle.deps) redshift-client s3transfer boto3;
|
|
17
|
+
snowflake-connector-python = let
|
|
18
|
+
pkg = bundle.deps.snowflake-connector-python.overridePythonAttrs (old: {
|
|
19
|
+
version = "3.14.0";
|
|
20
|
+
src = nixpkgs.fetchFromGitHub {
|
|
21
|
+
owner = "snowflakedb";
|
|
22
|
+
repo = "snowflake-connector-python";
|
|
23
|
+
tag = "v3.14.0";
|
|
24
|
+
hash = "sha256-r3g+eVVyK9t5qpAGvimapuWilAh3eHJEFUw8VBwtKw8=";
|
|
25
|
+
};
|
|
26
|
+
disabledTestPaths = old.disabledTestPaths ++ [
|
|
27
|
+
"test/unit/test_wiremock_client.py"
|
|
28
|
+
"test/unit/test_put_get.py"
|
|
29
|
+
];
|
|
30
|
+
});
|
|
31
|
+
in pynix.utils.compose [
|
|
32
|
+
pynix.patch.homelessPatch
|
|
33
|
+
pynix.patch.disableChecks
|
|
34
|
+
] pkg;
|
|
35
|
+
};
|
|
36
|
+
in {
|
|
37
|
+
inherit extended_python_pkgs;
|
|
38
|
+
pkg = bundle.builders.pkgBuilder
|
|
39
|
+
(bundle.builders.requirements extended_python_pkgs);
|
|
40
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
{
|
|
2
|
+
"nodes": {
|
|
3
|
+
"etl_utils": {
|
|
4
|
+
"inputs": {
|
|
5
|
+
"observes_flake_builder": [
|
|
6
|
+
"observes_flake_builder"
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"locked": {
|
|
10
|
+
"dir": "observes/common/etl-utils",
|
|
11
|
+
"lastModified": 1760615285,
|
|
12
|
+
"narHash": "sha256-Es+4RZ/ZvNz/xEbhMlWoUrebj7YvXysTVfwY20p0nKs=",
|
|
13
|
+
"owner": "fluidattacks",
|
|
14
|
+
"repo": "universe",
|
|
15
|
+
"rev": "d5147093dbd95ca7740d40a542650b9e2573f941",
|
|
16
|
+
"type": "github"
|
|
17
|
+
},
|
|
18
|
+
"original": {
|
|
19
|
+
"dir": "observes/common/etl-utils",
|
|
20
|
+
"owner": "fluidattacks",
|
|
21
|
+
"repo": "universe",
|
|
22
|
+
"rev": "d5147093dbd95ca7740d40a542650b9e2573f941",
|
|
23
|
+
"type": "github"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"flake-parts": {
|
|
27
|
+
"inputs": {
|
|
28
|
+
"nixpkgs-lib": "nixpkgs-lib"
|
|
29
|
+
},
|
|
30
|
+
"locked": {
|
|
31
|
+
"lastModified": 1754487366,
|
|
32
|
+
"narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=",
|
|
33
|
+
"owner": "hercules-ci",
|
|
34
|
+
"repo": "flake-parts",
|
|
35
|
+
"rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18",
|
|
36
|
+
"type": "github"
|
|
37
|
+
},
|
|
38
|
+
"original": {
|
|
39
|
+
"owner": "hercules-ci",
|
|
40
|
+
"repo": "flake-parts",
|
|
41
|
+
"type": "github"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"nix_filter": {
|
|
45
|
+
"locked": {
|
|
46
|
+
"lastModified": 1731533336,
|
|
47
|
+
"narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=",
|
|
48
|
+
"owner": "numtide",
|
|
49
|
+
"repo": "nix-filter",
|
|
50
|
+
"rev": "f7653272fd234696ae94229839a99b73c9ab7de0",
|
|
51
|
+
"type": "github"
|
|
52
|
+
},
|
|
53
|
+
"original": {
|
|
54
|
+
"owner": "numtide",
|
|
55
|
+
"repo": "nix-filter",
|
|
56
|
+
"type": "github"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"nix_filter_2": {
|
|
60
|
+
"locked": {
|
|
61
|
+
"lastModified": 1731533336,
|
|
62
|
+
"narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=",
|
|
63
|
+
"owner": "numtide",
|
|
64
|
+
"repo": "nix-filter",
|
|
65
|
+
"rev": "f7653272fd234696ae94229839a99b73c9ab7de0",
|
|
66
|
+
"type": "github"
|
|
67
|
+
},
|
|
68
|
+
"original": {
|
|
69
|
+
"owner": "numtide",
|
|
70
|
+
"repo": "nix-filter",
|
|
71
|
+
"type": "github"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"nixpkgs": {
|
|
75
|
+
"locked": {
|
|
76
|
+
"lastModified": 1736441877,
|
|
77
|
+
"narHash": "sha256-m3+PhBFkDwqo9lBplG4AyMW8P4/KcioJRS1UG8N7okM=",
|
|
78
|
+
"owner": "nixos",
|
|
79
|
+
"repo": "nixpkgs",
|
|
80
|
+
"rev": "ce3899414dab3297cf025bfa356dc2da426feefd",
|
|
81
|
+
"type": "github"
|
|
82
|
+
},
|
|
83
|
+
"original": {
|
|
84
|
+
"owner": "nixos",
|
|
85
|
+
"repo": "nixpkgs",
|
|
86
|
+
"type": "github"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"nixpkgs-lib": {
|
|
90
|
+
"locked": {
|
|
91
|
+
"lastModified": 1753579242,
|
|
92
|
+
"narHash": "sha256-zvaMGVn14/Zz8hnp4VWT9xVnhc8vuL3TStRqwk22biA=",
|
|
93
|
+
"owner": "nix-community",
|
|
94
|
+
"repo": "nixpkgs.lib",
|
|
95
|
+
"rev": "0f36c44e01a6129be94e3ade315a5883f0228a6e",
|
|
96
|
+
"type": "github"
|
|
97
|
+
},
|
|
98
|
+
"original": {
|
|
99
|
+
"owner": "nix-community",
|
|
100
|
+
"repo": "nixpkgs.lib",
|
|
101
|
+
"type": "github"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"nixpkgs_flake": {
|
|
105
|
+
"locked": {
|
|
106
|
+
"lastModified": 1756313514,
|
|
107
|
+
"narHash": "sha256-3Xbak0pXR8ziNv1ghHyJ5a5Ti2kt/LWq6hKZVJTvjBs=",
|
|
108
|
+
"owner": "nixos",
|
|
109
|
+
"repo": "nixpkgs",
|
|
110
|
+
"rev": "181464235b2daff8725773fef43ffc9d6b02e1c2",
|
|
111
|
+
"type": "github"
|
|
112
|
+
},
|
|
113
|
+
"original": {
|
|
114
|
+
"owner": "nixos",
|
|
115
|
+
"repo": "nixpkgs",
|
|
116
|
+
"type": "github"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"observes_flake_builder": {
|
|
120
|
+
"inputs": {
|
|
121
|
+
"nix_filter": "nix_filter",
|
|
122
|
+
"nixpkgs_flake": "nixpkgs_flake",
|
|
123
|
+
"pynix_flake": "pynix_flake",
|
|
124
|
+
"shell-helpers": "shell-helpers"
|
|
125
|
+
},
|
|
126
|
+
"locked": {
|
|
127
|
+
"dir": "observes/common/std_flake",
|
|
128
|
+
"lastModified": 1760615285,
|
|
129
|
+
"narHash": "sha256-Es+4RZ/ZvNz/xEbhMlWoUrebj7YvXysTVfwY20p0nKs=",
|
|
130
|
+
"owner": "fluidattacks",
|
|
131
|
+
"repo": "universe",
|
|
132
|
+
"rev": "d5147093dbd95ca7740d40a542650b9e2573f941",
|
|
133
|
+
"type": "github"
|
|
134
|
+
},
|
|
135
|
+
"original": {
|
|
136
|
+
"dir": "observes/common/std_flake",
|
|
137
|
+
"owner": "fluidattacks",
|
|
138
|
+
"repo": "universe",
|
|
139
|
+
"rev": "d5147093dbd95ca7740d40a542650b9e2573f941",
|
|
140
|
+
"type": "github"
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"pynix_flake": {
|
|
144
|
+
"inputs": {
|
|
145
|
+
"nix_filter": "nix_filter_2",
|
|
146
|
+
"nixpkgs": "nixpkgs"
|
|
147
|
+
},
|
|
148
|
+
"locked": {
|
|
149
|
+
"lastModified": 1758642502,
|
|
150
|
+
"narHash": "sha256-PD/bQMz2dqZSkydHyvRh+jS/0qoV8SdcIVs6sassteQ=",
|
|
151
|
+
"owner": "dmurciaatfluid",
|
|
152
|
+
"repo": "python_nix_builder",
|
|
153
|
+
"rev": "809aafe2e1995e72c15378d099bf251b78f04a20",
|
|
154
|
+
"type": "gitlab"
|
|
155
|
+
},
|
|
156
|
+
"original": {
|
|
157
|
+
"owner": "dmurciaatfluid",
|
|
158
|
+
"repo": "python_nix_builder",
|
|
159
|
+
"type": "gitlab"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
"root": {
|
|
163
|
+
"inputs": {
|
|
164
|
+
"etl_utils": "etl_utils",
|
|
165
|
+
"observes_flake_builder": "observes_flake_builder"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"shell-helpers": {
|
|
169
|
+
"inputs": {
|
|
170
|
+
"flake-parts": "flake-parts",
|
|
171
|
+
"nixpkgs": [
|
|
172
|
+
"observes_flake_builder",
|
|
173
|
+
"nixpkgs_flake"
|
|
174
|
+
]
|
|
175
|
+
},
|
|
176
|
+
"locked": {
|
|
177
|
+
"dir": "common/utils/shell-helpers",
|
|
178
|
+
"lastModified": 1752896460,
|
|
179
|
+
"narHash": "sha256-AsyTatXMx839cGsF6knwTrDZHk3Eue2QD3eSP7bkmpg=",
|
|
180
|
+
"owner": "fluidattacks",
|
|
181
|
+
"repo": "universe",
|
|
182
|
+
"rev": "27749d2c3a2b018eb010a322e5e1352f993c9e86",
|
|
183
|
+
"type": "github"
|
|
184
|
+
},
|
|
185
|
+
"original": {
|
|
186
|
+
"dir": "common/utils/shell-helpers",
|
|
187
|
+
"owner": "fluidattacks",
|
|
188
|
+
"repo": "universe",
|
|
189
|
+
"rev": "27749d2c3a2b018eb010a322e5e1352f993c9e86",
|
|
190
|
+
"type": "github"
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"root": "root",
|
|
195
|
+
"version": 7
|
|
196
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
description = "Utils for snowflake connection";
|
|
3
|
+
|
|
4
|
+
inputs = {
|
|
5
|
+
observes_flake_builder = {
|
|
6
|
+
url =
|
|
7
|
+
"github:fluidattacks/universe/d5147093dbd95ca7740d40a542650b9e2573f941?shallow=1&dir=observes/common/std_flake";
|
|
8
|
+
};
|
|
9
|
+
etl_utils = {
|
|
10
|
+
url =
|
|
11
|
+
"github:fluidattacks/universe/d5147093dbd95ca7740d40a542650b9e2573f941?shallow=1&dir=observes/common/etl-utils";
|
|
12
|
+
inputs.observes_flake_builder.follows = "observes_flake_builder";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
outputs = { self, ... }@inputs:
|
|
17
|
+
let
|
|
18
|
+
build_args = { system, python_version, nixpkgs, pynix }:
|
|
19
|
+
let
|
|
20
|
+
with_python = bundle: bundle.packages."${system}"."${python_version}";
|
|
21
|
+
in import ./build {
|
|
22
|
+
inherit nixpkgs pynix;
|
|
23
|
+
src = import ./build/filter.nix nixpkgs.nix-filter self;
|
|
24
|
+
local_lib = { etl_utils_bundle = with_python inputs.etl_utils; };
|
|
25
|
+
};
|
|
26
|
+
in { packages = inputs.observes_flake_builder.outputs.build build_args; };
|
|
27
|
+
}
|
|
28
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
from ._common import (
|
|
2
|
+
ClientAdapter,
|
|
3
|
+
CommonSchemaClient,
|
|
4
|
+
CommonTableClient,
|
|
5
|
+
)
|
|
6
|
+
from ._connection import (
|
|
7
|
+
ConnectionConf,
|
|
8
|
+
ConnectionManager,
|
|
9
|
+
ConnectionManagerFactory,
|
|
10
|
+
Databases,
|
|
11
|
+
DbClients,
|
|
12
|
+
Roles,
|
|
13
|
+
SetupException,
|
|
14
|
+
Warehouses,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
__version__ = "1.0.0"
|
|
18
|
+
|
|
19
|
+
__all__ = [
|
|
20
|
+
"ClientAdapter",
|
|
21
|
+
"CommonSchemaClient",
|
|
22
|
+
"CommonTableClient",
|
|
23
|
+
"ConnectionConf",
|
|
24
|
+
"ConnectionManager",
|
|
25
|
+
"ConnectionManagerFactory",
|
|
26
|
+
"Databases",
|
|
27
|
+
"DbClients",
|
|
28
|
+
"Roles",
|
|
29
|
+
"SetupException",
|
|
30
|
+
"Warehouses",
|
|
31
|
+
]
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
from dataclasses import (
|
|
2
|
+
dataclass,
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
from fa_purity import (
|
|
6
|
+
Cmd,
|
|
7
|
+
FrozenDict,
|
|
8
|
+
Maybe,
|
|
9
|
+
PureIter,
|
|
10
|
+
ResultE,
|
|
11
|
+
)
|
|
12
|
+
from fluidattacks_etl_utils.typing import (
|
|
13
|
+
Callable,
|
|
14
|
+
FrozenSet,
|
|
15
|
+
)
|
|
16
|
+
from redshift_client.client import (
|
|
17
|
+
GroupedRows,
|
|
18
|
+
)
|
|
19
|
+
from redshift_client.client import (
|
|
20
|
+
SchemaClient as RedshiftSchemaClient,
|
|
21
|
+
)
|
|
22
|
+
from redshift_client.client import (
|
|
23
|
+
TableClient as RedshiftTableClient,
|
|
24
|
+
)
|
|
25
|
+
from redshift_client.core.column import (
|
|
26
|
+
Column,
|
|
27
|
+
ColumnObj,
|
|
28
|
+
)
|
|
29
|
+
from redshift_client.core.id_objs import (
|
|
30
|
+
ColumnId,
|
|
31
|
+
DbTableId,
|
|
32
|
+
SchemaId,
|
|
33
|
+
TableId,
|
|
34
|
+
)
|
|
35
|
+
from redshift_client.core.table import (
|
|
36
|
+
DistStyle,
|
|
37
|
+
SortKeys,
|
|
38
|
+
Table,
|
|
39
|
+
TableAttrs,
|
|
40
|
+
)
|
|
41
|
+
from redshift_client.sql_client import (
|
|
42
|
+
Limit,
|
|
43
|
+
RowData,
|
|
44
|
+
)
|
|
45
|
+
from snowflake_client import (
|
|
46
|
+
SchemaClient,
|
|
47
|
+
TableClient,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
BluePrint = DbTableId
|
|
51
|
+
NewTable = DbTableId
|
|
52
|
+
Source = DbTableId
|
|
53
|
+
Target = DbTableId
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass(frozen=True, kw_only=True)
|
|
57
|
+
class CommonTableClient:
|
|
58
|
+
"""Table client interface. See factory method documentation for further details."""
|
|
59
|
+
|
|
60
|
+
get: Callable[[DbTableId], Cmd[ResultE[Table]]]
|
|
61
|
+
exist: Callable[[DbTableId], Cmd[ResultE[bool]]]
|
|
62
|
+
insert: Callable[[DbTableId, Table, PureIter[RowData], Limit], Cmd[ResultE[None]]]
|
|
63
|
+
named_insert: Callable[[DbTableId, GroupedRows], Cmd[ResultE[None]]]
|
|
64
|
+
rename: Callable[[DbTableId, str], Cmd[ResultE[TableId]]]
|
|
65
|
+
delete: Callable[[DbTableId], Cmd[ResultE[None]]]
|
|
66
|
+
delete_cascade: Callable[[DbTableId], Cmd[ResultE[None]]]
|
|
67
|
+
add_column: Callable[[DbTableId, ColumnObj], Cmd[ResultE[None]]]
|
|
68
|
+
add_columns: Callable[[DbTableId, FrozenDict[ColumnId, Column]], Cmd[ResultE[None]]]
|
|
69
|
+
new: Callable[[DbTableId, Table], Cmd[ResultE[None]]]
|
|
70
|
+
new_if_not_exist: Callable[[DbTableId, Table], Cmd[ResultE[None]]]
|
|
71
|
+
create_like: Callable[[BluePrint, NewTable], Cmd[ResultE[None]]]
|
|
72
|
+
move_data: Callable[[Source, Target], Cmd[ResultE[None]]]
|
|
73
|
+
move: Callable[[Source, Target], Cmd[ResultE[None]]]
|
|
74
|
+
migrate: Callable[[Source, Target], Cmd[ResultE[None]]]
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
@dataclass(frozen=True, kw_only=True)
|
|
78
|
+
class CommonSchemaClient:
|
|
79
|
+
all_schemas: Cmd[ResultE[FrozenSet[SchemaId]]]
|
|
80
|
+
table_ids: Callable[[SchemaId], Cmd[ResultE[FrozenSet[DbTableId]]]]
|
|
81
|
+
exist: Callable[[SchemaId], Cmd[ResultE[bool]]]
|
|
82
|
+
delete: Callable[[SchemaId], Cmd[ResultE[None]]]
|
|
83
|
+
delete_cascade: Callable[[SchemaId], Cmd[ResultE[None]]]
|
|
84
|
+
rename: Callable[[SchemaId, SchemaId], Cmd[ResultE[None]]]
|
|
85
|
+
create: Callable[[SchemaId], Cmd[ResultE[None]]]
|
|
86
|
+
create_if_not_exist: Callable[[SchemaId], Cmd[ResultE[None]]]
|
|
87
|
+
recreate: Callable[[SchemaId], Cmd[ResultE[None]]]
|
|
88
|
+
recreate_cascade: Callable[[SchemaId], Cmd[ResultE[None]]]
|
|
89
|
+
migrate: Callable[[SchemaId, SchemaId], Cmd[ResultE[None]]]
|
|
90
|
+
move: Callable[[SchemaId, SchemaId], Cmd[ResultE[None]]]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@dataclass(frozen=True)
|
|
94
|
+
class ClientAdapter:
|
|
95
|
+
@staticmethod
|
|
96
|
+
def snowflake_table_client_adapter(
|
|
97
|
+
client: TableClient,
|
|
98
|
+
) -> CommonTableClient:
|
|
99
|
+
return CommonTableClient(
|
|
100
|
+
get=client.get,
|
|
101
|
+
exist=client.exist,
|
|
102
|
+
insert=client.insert,
|
|
103
|
+
named_insert=client.named_insert,
|
|
104
|
+
rename=client.rename,
|
|
105
|
+
delete=client.delete,
|
|
106
|
+
delete_cascade=client.delete_cascade,
|
|
107
|
+
add_column=client.add_column,
|
|
108
|
+
add_columns=client.add_columns,
|
|
109
|
+
new=client.new,
|
|
110
|
+
new_if_not_exist=client.new_if_not_exist,
|
|
111
|
+
create_like=client.create_like,
|
|
112
|
+
move_data=client.move_data,
|
|
113
|
+
move=client.move,
|
|
114
|
+
migrate=client.migrate,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
@staticmethod
|
|
118
|
+
def redshift_table_client_adapter(
|
|
119
|
+
client: RedshiftTableClient,
|
|
120
|
+
) -> CommonTableClient:
|
|
121
|
+
return CommonTableClient(
|
|
122
|
+
get=client.get,
|
|
123
|
+
exist=client.exist,
|
|
124
|
+
insert=client.insert,
|
|
125
|
+
named_insert=client.named_insert,
|
|
126
|
+
rename=client.rename,
|
|
127
|
+
delete=client.delete,
|
|
128
|
+
delete_cascade=client.delete_cascade,
|
|
129
|
+
add_column=client.add_column,
|
|
130
|
+
add_columns=client.add_columns,
|
|
131
|
+
new=lambda i, t: client.new(
|
|
132
|
+
i,
|
|
133
|
+
t,
|
|
134
|
+
TableAttrs(DistStyle.AUTO, Maybe.empty(), True, SortKeys.auto()),
|
|
135
|
+
),
|
|
136
|
+
new_if_not_exist=lambda i, t: client.new_if_not_exist(
|
|
137
|
+
i,
|
|
138
|
+
t,
|
|
139
|
+
TableAttrs(DistStyle.AUTO, Maybe.empty(), True, SortKeys.auto()),
|
|
140
|
+
),
|
|
141
|
+
create_like=client.create_like,
|
|
142
|
+
move_data=client.move_data,
|
|
143
|
+
move=client.move,
|
|
144
|
+
migrate=client.migrate,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
@staticmethod
|
|
148
|
+
def _schema_client_adapter(
|
|
149
|
+
client: SchemaClient | RedshiftSchemaClient,
|
|
150
|
+
) -> CommonSchemaClient:
|
|
151
|
+
return CommonSchemaClient(
|
|
152
|
+
all_schemas=client.all_schemas,
|
|
153
|
+
table_ids=client.table_ids,
|
|
154
|
+
exist=client.exist,
|
|
155
|
+
delete=client.delete,
|
|
156
|
+
delete_cascade=client.delete_cascade,
|
|
157
|
+
rename=client.rename,
|
|
158
|
+
create=client.create,
|
|
159
|
+
create_if_not_exist=client.create_if_not_exist,
|
|
160
|
+
recreate=client.recreate,
|
|
161
|
+
recreate_cascade=client.recreate_cascade,
|
|
162
|
+
migrate=client.migrate,
|
|
163
|
+
move=client.move,
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
@classmethod
|
|
167
|
+
def snowflake_schema_client_adapter(
|
|
168
|
+
cls,
|
|
169
|
+
client: SchemaClient,
|
|
170
|
+
) -> CommonSchemaClient:
|
|
171
|
+
return cls._schema_client_adapter(client)
|
|
172
|
+
|
|
173
|
+
@classmethod
|
|
174
|
+
def redshift_schema_client_adapter(
|
|
175
|
+
cls,
|
|
176
|
+
client: RedshiftSchemaClient,
|
|
177
|
+
) -> CommonSchemaClient:
|
|
178
|
+
return cls._schema_client_adapter(client)
|