everysk-lib 1.10.1__cp311-cp311-macosx_11_0_arm64.whl → 1.10.2__cp311-cp311-macosx_11_0_arm64.whl
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.
- everysk/sdk/brutils/cnpj.py +39 -21
- everysk/sdk/brutils/cnpj_pd.py +94 -7
- everysk/sdk/engines/expression.cpython-311-darwin.so +0 -0
- everysk/sdk/engines/expression.pyi +7 -5
- everysk/sql/connection.py +6 -1
- everysk/sql/query.py +30 -6
- everysk/sql/settings.py +4 -0
- {everysk_lib-1.10.1.dist-info → everysk_lib-1.10.2.dist-info}/METADATA +1 -1
- {everysk_lib-1.10.1.dist-info → everysk_lib-1.10.2.dist-info}/RECORD +13 -13
- {everysk_lib-1.10.1.dist-info → everysk_lib-1.10.2.dist-info}/WHEEL +1 -1
- {everysk_lib-1.10.1.dist-info → everysk_lib-1.10.2.dist-info}/.gitignore +0 -0
- {everysk_lib-1.10.1.dist-info → everysk_lib-1.10.2.dist-info}/licenses/LICENSE.txt +0 -0
- {everysk_lib-1.10.1.dist-info → everysk_lib-1.10.2.dist-info}/top_level.txt +0 -0
everysk/sdk/brutils/cnpj.py
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
# without authorization of EVERYSK TECHNOLOGIES is prohibited.
|
|
8
8
|
#
|
|
9
9
|
###############################################################################
|
|
10
|
-
import random
|
|
11
10
|
import re
|
|
11
|
+
import secrets
|
|
12
12
|
import string
|
|
13
13
|
|
|
14
14
|
from everysk.core.fields import IntField, TupleField
|
|
@@ -19,6 +19,7 @@ from everysk.core.fields import IntField, TupleField
|
|
|
19
19
|
|
|
20
20
|
CNPJ_LENGTH: IntField = IntField(default=14, readonly=True)
|
|
21
21
|
CNPJ_BASE_LENGTH: IntField = IntField(default=12, readonly=True)
|
|
22
|
+
CNPJ_D2: IntField = IntField(default=2, readonly=True)
|
|
22
23
|
|
|
23
24
|
WEIGHTS_DV1: TupleField = TupleField(default=(5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2), readonly=True)
|
|
24
25
|
WEIGHTS_DV2: TupleField = TupleField(default=(6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2), readonly=True)
|
|
@@ -56,7 +57,7 @@ class CNPJ:
|
|
|
56
57
|
The verification digits (last 2 digits) of the CNPJ.
|
|
57
58
|
"""
|
|
58
59
|
|
|
59
|
-
def __init__(self, cnpj: str | int | float | None):
|
|
60
|
+
def __init__(self, cnpj: str | int | float | None) -> None:
|
|
60
61
|
"""
|
|
61
62
|
Initialize the instance with a CNPJ value.
|
|
62
63
|
|
|
@@ -85,6 +86,18 @@ class CNPJ:
|
|
|
85
86
|
"""
|
|
86
87
|
return f"{self.__class__.__name__}('{self.cnpj}')"
|
|
87
88
|
|
|
89
|
+
def _raise_cnpj_exception(self, message: str) -> None:
|
|
90
|
+
"""
|
|
91
|
+
Raises a CNPJError with the provided error message.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
message (str): The error message to include in the exception.
|
|
95
|
+
|
|
96
|
+
Raises:
|
|
97
|
+
CNPJError: Always raised with the given message.
|
|
98
|
+
"""
|
|
99
|
+
raise CNPJError(message)
|
|
100
|
+
|
|
88
101
|
@property
|
|
89
102
|
def firm(self) -> str:
|
|
90
103
|
"""
|
|
@@ -127,12 +140,12 @@ class CNPJ:
|
|
|
127
140
|
return self.cnpj[CNPJ_BASE_LENGTH.default :]
|
|
128
141
|
return None
|
|
129
142
|
|
|
130
|
-
def sanitize(self, zfill: bool = True) -> str | None:
|
|
143
|
+
def sanitize(self, *, zfill: bool = True) -> str | None:
|
|
131
144
|
"""
|
|
132
145
|
Sanitize a CNPJ string.
|
|
133
146
|
|
|
134
147
|
- Removes non-alphanumeric characters
|
|
135
|
-
-
|
|
148
|
+
- Uppercase letters
|
|
136
149
|
- If zfill=True, left-pads with zeros until length == 14
|
|
137
150
|
|
|
138
151
|
Parameters
|
|
@@ -174,7 +187,7 @@ class CNPJ:
|
|
|
174
187
|
|
|
175
188
|
return self.cnpj
|
|
176
189
|
|
|
177
|
-
def normalize(self, zfill: bool = False, errors: str = 'raise') -> str | None:
|
|
190
|
+
def normalize(self, *, zfill: bool = False, errors: str = 'raise') -> str | None:
|
|
178
191
|
"""
|
|
179
192
|
Normalize a CNPJ with structural validation only (no DV check).
|
|
180
193
|
|
|
@@ -205,16 +218,16 @@ class CNPJ:
|
|
|
205
218
|
self.sanitize(zfill=zfill)
|
|
206
219
|
|
|
207
220
|
if self.cnpj is None:
|
|
208
|
-
|
|
221
|
+
self._raise_cnpj_exception('CNPJ is None.')
|
|
209
222
|
|
|
210
223
|
if not self.is_valid(check_dv=False):
|
|
211
|
-
|
|
224
|
+
self._raise_cnpj_exception('CNPJ validation failed.')
|
|
212
225
|
|
|
213
|
-
except CNPJError
|
|
226
|
+
except CNPJError:
|
|
214
227
|
if errors == 'coerce':
|
|
215
228
|
self.cnpj = None
|
|
216
229
|
if errors == 'raise':
|
|
217
|
-
raise
|
|
230
|
+
raise
|
|
218
231
|
|
|
219
232
|
return self.cnpj
|
|
220
233
|
|
|
@@ -236,14 +249,18 @@ class CNPJ:
|
|
|
236
249
|
CNPJError: If `ch` is not a single character or is not alphanumeric.
|
|
237
250
|
"""
|
|
238
251
|
if len(ch) != 1:
|
|
239
|
-
|
|
252
|
+
self._raise_cnpj_exception(f'Invalid character {ch!r}: must be a single character')
|
|
253
|
+
|
|
240
254
|
if not ch.isalnum():
|
|
241
|
-
|
|
255
|
+
self._raise_cnpj_exception(f'Invalid character {ch!r}: must be alphanumeric')
|
|
256
|
+
|
|
242
257
|
return ord(ch.upper()) - 48
|
|
243
258
|
|
|
244
259
|
def _calc_dv(self, payload: str, weights: tuple[int, ...]) -> str:
|
|
245
260
|
"""
|
|
246
261
|
Calculates a single check digit (DV) using the modulo 11 algorithm.
|
|
262
|
+
Se o resto for 0 ou 1, o D2 é 0.
|
|
263
|
+
Se o resto for diferente de 0 ou 1, o D2 é 11 - resto.
|
|
247
264
|
|
|
248
265
|
Args:
|
|
249
266
|
payload (str): The input string for which the check digit is to be calculated.
|
|
@@ -255,9 +272,9 @@ class CNPJ:
|
|
|
255
272
|
Note:
|
|
256
273
|
This is an internal method used for check digit calculation in Brazilian document validation.
|
|
257
274
|
"""
|
|
258
|
-
total = sum(self._ascii48_value(ch) * w for ch, w in zip(payload, weights))
|
|
275
|
+
total = sum(self._ascii48_value(ch) * w for ch, w in zip(payload, weights, strict=True))
|
|
259
276
|
result = total % 11
|
|
260
|
-
return '0' if result <
|
|
277
|
+
return '0' if result < CNPJ_D2.default else str(11 - result)
|
|
261
278
|
|
|
262
279
|
def _calc_dvs_from_base(self, base: str) -> str:
|
|
263
280
|
"""
|
|
@@ -273,15 +290,16 @@ class CNPJ:
|
|
|
273
290
|
CNPJError: If the base is not exactly 12 alphanumeric characters.
|
|
274
291
|
"""
|
|
275
292
|
if len(base) != CNPJ_BASE_LENGTH.default or not all(ch.isalnum() for ch in base):
|
|
276
|
-
|
|
293
|
+
self._raise_cnpj_exception('Base must be exactly 12 alphanumeric characters')
|
|
294
|
+
|
|
277
295
|
dv1 = self._calc_dv(base, WEIGHTS_DV1.default)
|
|
278
296
|
dv2 = self._calc_dv(f'{base}{dv1}', WEIGHTS_DV2.default)
|
|
279
297
|
return f'{dv1}{dv2}'
|
|
280
298
|
|
|
281
|
-
def is_valid(self, check_dv: bool = False) -> bool:
|
|
299
|
+
def is_valid(self, *, check_dv: bool = False) -> bool:
|
|
282
300
|
"""
|
|
283
301
|
Validate a *sanitized* CNPJ (14 chars).
|
|
284
|
-
If instantiated with
|
|
302
|
+
If instantiated with a not sanitized CNPJ, call self.sanitize() first.
|
|
285
303
|
|
|
286
304
|
Parameters
|
|
287
305
|
----------
|
|
@@ -335,7 +353,7 @@ class CNPJ:
|
|
|
335
353
|
return f'{self.cnpj[0:2]}.{self.cnpj[2:5]}.{self.cnpj[5:8]}/{self.cnpj[8:12]}-{self.cnpj[12:]}'
|
|
336
354
|
|
|
337
355
|
@staticmethod
|
|
338
|
-
def generate_random(valid_dv: bool = True) -> str:
|
|
356
|
+
def generate_random(valid_dv: bool = True) -> str: # noqa: FBT001, FBT002
|
|
339
357
|
"""
|
|
340
358
|
Generate a random CNPJ using the new alphanumeric base format.
|
|
341
359
|
|
|
@@ -350,7 +368,7 @@ class CNPJ:
|
|
|
350
368
|
str
|
|
351
369
|
Sanitized 14-character CNPJ.
|
|
352
370
|
"""
|
|
353
|
-
base = ''.join(
|
|
371
|
+
base = ''.join(secrets.choice(BASE_VALUES) for _ in range(CNPJ_BASE_LENGTH.default))
|
|
354
372
|
|
|
355
373
|
# To avoid calling cls from a staticmethod, compute using local helpers:
|
|
356
374
|
# We'll re-use the module-level logic through a lightweight inline calc.
|
|
@@ -358,9 +376,9 @@ class CNPJ:
|
|
|
358
376
|
return ord(ch.upper()) - 48
|
|
359
377
|
|
|
360
378
|
def calc_dv(payload: str, weights: tuple[int, ...]) -> str:
|
|
361
|
-
total = sum(ascii48_value(ch) * w for ch, w in zip(payload, weights))
|
|
379
|
+
total = sum(ascii48_value(ch) * w for ch, w in zip(payload, weights, strict=True))
|
|
362
380
|
rest = total % 11
|
|
363
|
-
return '0' if rest <
|
|
381
|
+
return '0' if rest < CNPJ_D2.default else str(11 - rest)
|
|
364
382
|
|
|
365
383
|
dv1 = calc_dv(base, WEIGHTS_DV1.default)
|
|
366
384
|
dv2 = calc_dv(f'{base}{dv1}', WEIGHTS_DV2.default)
|
|
@@ -369,5 +387,5 @@ class CNPJ:
|
|
|
369
387
|
if valid_dv:
|
|
370
388
|
return CNPJ(f'{base}{dvs}')
|
|
371
389
|
|
|
372
|
-
invalid_second_dv = str((int(dvs[1]) +
|
|
390
|
+
invalid_second_dv = str((int(dvs[1]) + secrets.randbelow(9) + 1) % 10)
|
|
373
391
|
return CNPJ(f'{base}{dvs[0]}{invalid_second_dv}')
|
everysk/sdk/brutils/cnpj_pd.py
CHANGED
|
@@ -23,20 +23,107 @@ class CNPJAccessor:
|
|
|
23
23
|
The pandas Series object containing CNPJ values.
|
|
24
24
|
"""
|
|
25
25
|
|
|
26
|
-
def __init__(self, pandas_obj):
|
|
26
|
+
def __init__(self, pandas_obj: pd.Series) -> None:
|
|
27
|
+
"""
|
|
28
|
+
Initializes the class with a pandas Series object.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
pandas_obj (pd.Series): The pandas Series to be associated with the instance.
|
|
32
|
+
"""
|
|
27
33
|
self._obj = pandas_obj
|
|
28
34
|
|
|
29
|
-
def sanitize(self, zfill: bool = True):
|
|
35
|
+
def sanitize(self, *, zfill: bool = True) -> pd.Series:
|
|
36
|
+
"""
|
|
37
|
+
Sanitizes each CNPJ value in the Series.
|
|
38
|
+
|
|
39
|
+
This method applies the `CNPJ.sanitize` function to each element of the Series,
|
|
40
|
+
removing any non-numeric characters and optionally zero-padding the result to 14 digits.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
zfill (bool, optional): If True, pads the sanitized CNPJ with leading zeros to ensure a length of 14 digits.
|
|
44
|
+
Defaults to True.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
pd.Series: A Series containing the sanitized CNPJ values.
|
|
48
|
+
"""
|
|
30
49
|
return self._obj.apply(lambda x: CNPJ(x).sanitize(zfill=zfill))
|
|
31
50
|
|
|
32
|
-
def normalize(self, zfill: bool = False, errors: str = 'raise'):
|
|
51
|
+
def normalize(self, *, zfill: bool = False, errors: str = 'raise') -> pd.Series:
|
|
52
|
+
"""
|
|
53
|
+
Normalize CNPJ numbers in the Series.
|
|
54
|
+
|
|
55
|
+
This method applies normalization to each CNPJ value in the Series, optionally zero-filling
|
|
56
|
+
the result to 14 digits. Invalid CNPJ values can be handled according to the `errors` parameter.
|
|
57
|
+
|
|
58
|
+
Parameters
|
|
59
|
+
----------
|
|
60
|
+
zfill : bool, default False
|
|
61
|
+
If True, pad the CNPJ with leading zeros to ensure a length of 14 digits.
|
|
62
|
+
errors : {'raise', 'ignore', 'coerce'}, default 'raise'
|
|
63
|
+
Specifies how to handle invalid CNPJ values:
|
|
64
|
+
- 'raise': Raise an exception for invalid values.
|
|
65
|
+
- 'ignore': Return the original value for invalid entries.
|
|
66
|
+
- 'coerce': Replace invalid values with NaN.
|
|
67
|
+
|
|
68
|
+
Returns
|
|
69
|
+
-------
|
|
70
|
+
pd.Series
|
|
71
|
+
A pandas Series with normalized CNPJ numbers.
|
|
72
|
+
"""
|
|
33
73
|
return self._obj.apply(lambda x: CNPJ(x).normalize(zfill=zfill, errors=errors))
|
|
34
74
|
|
|
35
|
-
def is_valid(self, check_dv: bool = False):
|
|
75
|
+
def is_valid(self, *, check_dv: bool = False) -> pd.Series:
|
|
76
|
+
"""
|
|
77
|
+
Check if each CNPJ in the Series is valid.
|
|
78
|
+
|
|
79
|
+
Parameters
|
|
80
|
+
----------
|
|
81
|
+
check_dv : bool, optional
|
|
82
|
+
If True, also checks the verification digits (DV) of the CNPJ. Default is False.
|
|
83
|
+
|
|
84
|
+
Returns
|
|
85
|
+
-------
|
|
86
|
+
pd.Series
|
|
87
|
+
A boolean Series indicating whether each CNPJ is valid.
|
|
88
|
+
"""
|
|
36
89
|
return self._obj.apply(lambda x: CNPJ(x).is_valid(check_dv=check_dv))
|
|
37
90
|
|
|
38
|
-
def format(self, errors: str = 'raise'):
|
|
91
|
+
def format(self, *, errors: str = 'raise') -> pd.Series:
|
|
92
|
+
"""
|
|
93
|
+
Formats each value in the Series as a CNPJ string.
|
|
94
|
+
|
|
95
|
+
Parameters
|
|
96
|
+
----------
|
|
97
|
+
errors : str, default 'raise'
|
|
98
|
+
Specifies how to handle parsing errors. If 'raise', an exception is raised for invalid CNPJ values.
|
|
99
|
+
|
|
100
|
+
Returns
|
|
101
|
+
-------
|
|
102
|
+
pd.Series
|
|
103
|
+
A Series with each value formatted as a CNPJ string.
|
|
104
|
+
|
|
105
|
+
Examples
|
|
106
|
+
--------
|
|
107
|
+
>>> s = pd.Series(['12345678000195', '11222333000181'])
|
|
108
|
+
>>> s.cnpj.format()
|
|
109
|
+
0 12.345.678/0001-95
|
|
110
|
+
1 11.222.333/0001-81
|
|
111
|
+
dtype: object
|
|
112
|
+
"""
|
|
39
113
|
return self._obj.apply(lambda x: CNPJ(x).format(errors=errors))
|
|
40
114
|
|
|
41
|
-
def generate(self, valid_dv: bool = True):
|
|
42
|
-
|
|
115
|
+
def generate(self, *, valid_dv: bool = True) -> pd.Series:
|
|
116
|
+
"""
|
|
117
|
+
Generate a pandas Series of random CNPJ numbers.
|
|
118
|
+
|
|
119
|
+
Each element in the Series is a randomly generated CNPJ string.
|
|
120
|
+
The validity of the check digits (DV) can be controlled via the `valid_dv` parameter.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
valid_dv (bool, optional): If True, generates CNPJs with valid check digits.
|
|
124
|
+
If False, generates CNPJs with invalid check digits. Defaults to True.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
pd.Series: A pandas Series containing randomly generated CNPJ strings.
|
|
128
|
+
"""
|
|
129
|
+
return self._obj.apply(lambda _: str(CNPJ.generate_random(valid_dv=valid_dv)))
|
|
Binary file
|
|
@@ -21,10 +21,12 @@ import everysk.config
|
|
|
21
21
|
import everysk.core
|
|
22
22
|
import everysk.core.log
|
|
23
23
|
import _frozen_importlib_external
|
|
24
|
-
import
|
|
24
|
+
import functools
|
|
25
25
|
import importlib
|
|
26
|
+
import inspect
|
|
26
27
|
import pkgutil
|
|
27
|
-
import
|
|
28
|
+
import collections
|
|
29
|
+
import collections.abc
|
|
28
30
|
import numpy
|
|
29
31
|
import pandas
|
|
30
32
|
import everysk.core.datetime
|
|
@@ -35,18 +37,18 @@ import everysk.sdk.engines.helpers
|
|
|
35
37
|
import everysk.sdk.engines.helpers.transform
|
|
36
38
|
import datetime
|
|
37
39
|
import everysk.core.datetime.date_mixin
|
|
38
|
-
import collections
|
|
39
|
-
import collections.abc
|
|
40
40
|
import everysk.sdk.engines.helpers.algorithms
|
|
41
41
|
import everysk.sdk.engines.helpers.mathematical
|
|
42
42
|
import collections.OrderedDict
|
|
43
|
+
import everysk.sdk.brutils
|
|
44
|
+
import everysk.sdk.brutils.cnpj
|
|
43
45
|
import everysk.sdk.engines.helpers.formater
|
|
44
46
|
import re
|
|
45
47
|
import unicodedata
|
|
46
48
|
import everysk.sdk.engines.cryptography
|
|
47
49
|
import unittest
|
|
48
|
-
import unittest.mock
|
|
49
50
|
import copy
|
|
51
|
+
import unittest.mock
|
|
50
52
|
import everysk.core.datetime.calendar
|
|
51
53
|
import lark.visitors
|
|
52
54
|
import decimal
|
everysk/sql/connection.py
CHANGED
|
@@ -95,6 +95,7 @@ def make_connection_dsn(
|
|
|
95
95
|
user: str | None = None,
|
|
96
96
|
password: str | None = None,
|
|
97
97
|
database: str | None = None,
|
|
98
|
+
sslmode: str | None = None,
|
|
98
99
|
) -> str:
|
|
99
100
|
"""
|
|
100
101
|
Create a PostgreSQL connection DSN from settings.
|
|
@@ -107,20 +108,24 @@ def make_connection_dsn(
|
|
|
107
108
|
user (str | None): The database user. If None, uses the setting.
|
|
108
109
|
password (str | None): The database password. If None, uses the setting.
|
|
109
110
|
database (str | None): The database name. If None, uses the setting.
|
|
111
|
+
sslmode (str | None): The SSL mode for connection. If None, uses the setting if defined.
|
|
110
112
|
"""
|
|
113
|
+
sslmode: str | None = sslmode or settings.POSTGRESQL_CONNECTION_SSLMODE
|
|
111
114
|
options: dict[str, str | int] = {
|
|
112
115
|
'host': host or settings.POSTGRESQL_CONNECTION_HOST,
|
|
113
116
|
'port': port or settings.POSTGRESQL_CONNECTION_PORT,
|
|
114
117
|
'user': user or settings.POSTGRESQL_CONNECTION_USER,
|
|
115
118
|
'password': password or settings.POSTGRESQL_CONNECTION_PASSWORD,
|
|
116
119
|
'database': database or settings.POSTGRESQL_CONNECTION_DATABASE,
|
|
120
|
+
'sslmode': f'?sslmode={sslmode}' if sslmode else '',
|
|
117
121
|
}
|
|
122
|
+
|
|
118
123
|
# Handle Unix socket connections
|
|
119
124
|
if options['host'].startswith('/'):
|
|
120
125
|
return 'postgresql:///{database}?host={host}&user={user}&password={password}'.format(**options)
|
|
121
126
|
|
|
122
127
|
# Standard TCP connection
|
|
123
|
-
return 'postgresql://{user}:{password}@{host}:{port}/{database}'.format(**options)
|
|
128
|
+
return 'postgresql://{user}:{password}@{host}:{port}/{database}{sslmode}'.format(**options)
|
|
124
129
|
|
|
125
130
|
|
|
126
131
|
def get_pool(dsn: str | None = None, **kwargs) -> ConnectionPool:
|
everysk/sql/query.py
CHANGED
|
@@ -52,7 +52,11 @@ _SQL_ORDER_BY = {'asc': 'ASC NULLS LAST', 'desc': 'DESC NULLS LAST'}
|
|
|
52
52
|
# SQL queries constants
|
|
53
53
|
|
|
54
54
|
# Create new schema
|
|
55
|
-
_SQL_CREATE_SCHEMA = 'CREATE SCHEMA IF NOT EXISTS "{schema}"'
|
|
55
|
+
_SQL_CREATE_SCHEMA = 'CREATE SCHEMA IF NOT EXISTS "{schema}"{authorization}'
|
|
56
|
+
|
|
57
|
+
# Create new role
|
|
58
|
+
# FEAT: add others Role Attributes if needed, like CREATEDB, etc.
|
|
59
|
+
_SQL_CREATE_ROLE = "CREATE ROLE {role_name} WITH LOGIN PASSWORD '{role_password}'"
|
|
56
60
|
|
|
57
61
|
## Use {name} when you need to replace a value in the query using the format method.
|
|
58
62
|
## Use %(name)s when you need to replace a value in the query using the execute method.
|
|
@@ -232,14 +236,34 @@ class Query:
|
|
|
232
236
|
return f'OFFSET {offset}'
|
|
233
237
|
|
|
234
238
|
## Public methods
|
|
235
|
-
def parse_create_schema(self) -> str:
|
|
239
|
+
def parse_create_schema(self, authorization: str | None = None) -> str:
|
|
240
|
+
"""
|
|
241
|
+
Generates a SQL statement to create a schema using the current schema name with optional authorization.
|
|
242
|
+
|
|
243
|
+
Args:
|
|
244
|
+
authorization (str | None, optional): The authorization role to assign to the schema.
|
|
245
|
+
If None, no authorization clause is added. Defaults to None.
|
|
246
|
+
To avoid to do alter schema with another SQL.
|
|
247
|
+
|
|
248
|
+
Returns:
|
|
249
|
+
str: The formatted SQL statement for creating the schema.
|
|
236
250
|
"""
|
|
237
|
-
|
|
251
|
+
return _SQL_CREATE_SCHEMA.format(
|
|
252
|
+
schema=self.schema, authorization=f' AUTHORIZATION {authorization}' if authorization else ''
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
def parse_create_role(self, role_name: str, role_password: str) -> str:
|
|
256
|
+
"""
|
|
257
|
+
Generates a SQL statement to create a role with the given name and password.
|
|
258
|
+
|
|
259
|
+
Args:
|
|
260
|
+
role_name (str): The name of the role to create.
|
|
261
|
+
role_password (str): The password for the role.
|
|
238
262
|
|
|
239
263
|
Returns:
|
|
240
|
-
str:
|
|
264
|
+
str: The formatted SQL statement for creating the role.
|
|
241
265
|
"""
|
|
242
|
-
return
|
|
266
|
+
return _SQL_CREATE_ROLE.format(role_name=role_name, role_password=role_password)
|
|
243
267
|
|
|
244
268
|
def parse_create_table(self, fields: dict[str, type]) -> str:
|
|
245
269
|
"""
|
|
@@ -373,9 +397,9 @@ class Query:
|
|
|
373
397
|
Returns:
|
|
374
398
|
tuple[str, dict]: A tuple containing the SQL query string and a dictionary of parameters for the query.
|
|
375
399
|
"""
|
|
400
|
+
# FEAT: treat specials like sum, count, avg, round, etc.
|
|
376
401
|
params = {
|
|
377
402
|
'schema': self.schema,
|
|
378
|
-
# TODO: treat specials like sum, count, avg, round, etc.
|
|
379
403
|
'fields': ', '.join([f'"{field}"' for field in fields]),
|
|
380
404
|
'table': self.table_name,
|
|
381
405
|
'limit': self._sql_limit(limit),
|
everysk/sql/settings.py
CHANGED
|
@@ -43,3 +43,7 @@ POSTGRESQL_POOL_RECONNECT_TIMEOUT: int = 60 * 2 # 2 minutes
|
|
|
43
43
|
# The default maximum time in seconds that a client can wait to receive a connection
|
|
44
44
|
# from the pool (using connection() or getconn()).
|
|
45
45
|
POSTGRESQL_POOL_TIMEOUT: int = 30 # 30 seconds
|
|
46
|
+
|
|
47
|
+
# e.g., 'require', 'verify-ca', 'verify-full'
|
|
48
|
+
# the default if not set is 'prefer' which means try an SSL connection first, and fallback to a non-SSL connection
|
|
49
|
+
POSTGRESQL_CONNECTION_SSLMODE: str = None
|
|
@@ -56,9 +56,9 @@ everysk/sdk/__init__.py,sha256=29vdTawyABE748i_4wFeavjhed92t9ZXOT2uqriIEmk,974
|
|
|
56
56
|
everysk/sdk/settings.py,sha256=S9l3ZwC6jZwTvr_bnQtvwXJSKFsRF7yKj2btptd3abs,3147
|
|
57
57
|
everysk/sdk/tests.py,sha256=pZPSxu2roMCLFWHhnZFCSlA4nv_mFkwqNBkDsVfZ8GU,7611
|
|
58
58
|
everysk/sdk/base.py,sha256=aOhguqj-WfyHYm_qO5G675JdF5iJKf6x0Abt4jYKb_8,3668
|
|
59
|
-
everysk/sdk/brutils/cnpj.py,sha256=
|
|
60
|
-
everysk/sdk/brutils/cnpj_pd.py,sha256=
|
|
61
|
-
everysk/sdk/engines/expression.cpython-311-darwin.so,sha256=
|
|
59
|
+
everysk/sdk/brutils/cnpj.py,sha256=mP_5X1xgnkHb2BP0a5AVUiYmGc3sOhXeQpWwjOoHQEU,13505
|
|
60
|
+
everysk/sdk/brutils/cnpj_pd.py,sha256=4qdRsM49sx0zCOtOkjpppymwvYlrzmx0fOk-xARmuD0,4698
|
|
61
|
+
everysk/sdk/engines/expression.cpython-311-darwin.so,sha256=kbemgB2lFq2vkcQhLwt-SGCX2GvMqFpdApahfrpKXFQ,5538288
|
|
62
62
|
everysk/sdk/engines/helpers.cpython-311-darwin.so,sha256=fDQie078ABMeS-mEHBe6Y60BQiqmKeQUUYTZJtNjY9k,1386016
|
|
63
63
|
everysk/sdk/engines/compliance.py,sha256=Kd2buYlcKfUHEGmeZrGgT2JOnC7p12UOlDwFS69ssEM,1432
|
|
64
64
|
everysk/sdk/engines/helpers.pyi,sha256=CIcomtg79QWisRscba-Trs0X4tOlMT1gxykZjM90KYA,482
|
|
@@ -68,7 +68,7 @@ everysk/sdk/engines/cryptography.py,sha256=y07mfKbNDK86j4CnfmqqdL2KWBf0s6WN7xjuL
|
|
|
68
68
|
everysk/sdk/engines/lock.py,sha256=rPFY3e2hrKiRyFE0iHAuMad7Cv0KQBJsF9SbZcx43D0,4709
|
|
69
69
|
everysk/sdk/engines/market_data.py,sha256=lyMl_IOAEobFzzo6Jrtxa9ht95BJEmTUR6bXkLGaZLM,9426
|
|
70
70
|
everysk/sdk/engines/settings.py,sha256=xTxOvPLk_4MXO1VzG78Dbawhu4wE7nmXchWoxVF1X0w,1139
|
|
71
|
-
everysk/sdk/engines/expression.pyi,sha256=
|
|
71
|
+
everysk/sdk/engines/expression.pyi,sha256=x-PzVPFPkMbs8Y05lMePnbGe9OgJSdjnUUWAj8tnEas,1324
|
|
72
72
|
everysk/sdk/entities/tags.py,sha256=n_hLlbCvhL6Bl0QlvfU4dSRVvwK-MuvRWa1tt2dL9xk,6189
|
|
73
73
|
everysk/sdk/entities/fields.py,sha256=t8W_sMvw7VZpA48HSh_SSW3H1dtF0P6xnZbqELc72xo,13087
|
|
74
74
|
everysk/sdk/entities/query.py,sha256=cCxsAWF01nLXlRHq8RsGoXLlffKf-QaPPfRvf22FPdg,24077
|
|
@@ -123,15 +123,15 @@ everysk/api/api_resources/report.py,sha256=FBEh4uEXd_OxE4BJmrQnbC9nBjGGSYt33HsKv
|
|
|
123
123
|
everysk/api/api_resources/datastore.py,sha256=ZFXkON1DH6M-Kui6nViwitH7L8vACRq1PKFLr8NtLdM,3250
|
|
124
124
|
everysk/api/api_resources/custom_index.py,sha256=Lk5ms54MLPs-vlKwkw-kyDjyFwsk-AD3OOYa-HHRc48,1382
|
|
125
125
|
everysk/sql/row_factory.py,sha256=FEtB4d12ACT3Bp6g2k_Ty2p2HpTkPoVqODUS1_kSXys,1936
|
|
126
|
-
everysk/sql/query.py,sha256=
|
|
126
|
+
everysk/sql/query.py,sha256=lHKLEBMQZl8KsNdPHSEuqHAMxPuJ0l161Qba9taQYsc,15265
|
|
127
127
|
everysk/sql/__init__.py,sha256=lXZAWXrI2tlzw9uvJyThaWnksZqdbemQ2tqe-e7wUiU,413
|
|
128
128
|
everysk/sql/model.py,sha256=syHHTTS4JRTj_2Mu9ugmMu4b6qUY12t3VgfE3hSxYIc,14559
|
|
129
|
-
everysk/sql/connection.py,sha256=
|
|
129
|
+
everysk/sql/connection.py,sha256=8_TGX9e7PfPDTZOELunENBVNPc8Tkz4AkBtqcXUVgqM,8938
|
|
130
130
|
everysk/sql/utils.py,sha256=Hbk9INEcz12FoBeDvHh9qh0dTSmTCWAn_S1anJOJb1o,4327
|
|
131
|
-
everysk/sql/settings.py,sha256=
|
|
132
|
-
everysk_lib-1.10.
|
|
133
|
-
everysk_lib-1.10.
|
|
134
|
-
everysk_lib-1.10.
|
|
135
|
-
everysk_lib-1.10.
|
|
136
|
-
everysk_lib-1.10.
|
|
137
|
-
everysk_lib-1.10.
|
|
131
|
+
everysk/sql/settings.py,sha256=vBfQrs0iFwr4rLIJfc3HxjJY3JqW5ONMHAeYrPhlSaU,2307
|
|
132
|
+
everysk_lib-1.10.2.dist-info/RECORD,,
|
|
133
|
+
everysk_lib-1.10.2.dist-info/WHEEL,sha256=hD43ZIWkM5lzdXKLZVKqywZFoqatzvS9BoYxwqWNkEI,137
|
|
134
|
+
everysk_lib-1.10.2.dist-info/.gitignore,sha256=0A1r9HzLhR7IQ1rGPjbaW5HC6oIQ7xzVYZ1z1ZaVfmw,183
|
|
135
|
+
everysk_lib-1.10.2.dist-info/top_level.txt,sha256=1s1Lfhd4gXolqzkh-ay3yy-EZKPiKnJfbZwx2fybxyk,14
|
|
136
|
+
everysk_lib-1.10.2.dist-info/METADATA,sha256=nFU6EM4YdIvDe5VLRczGrCM7KTBMefu0P8-vZyWGBjU,13080
|
|
137
|
+
everysk_lib-1.10.2.dist-info/licenses/LICENSE.txt,sha256=Q5YxWA62m0TsmpEmHeoRHg4oPu_8ektkZ3FWWm1pQWo,311
|
|
File without changes
|
|
File without changes
|
|
File without changes
|