sqlalchemy-cratedb 0.38.0__py3-none-any.whl → 0.38.0.dev0__py3-none-any.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.
- sqlalchemy_cratedb/compiler.py +6 -16
- sqlalchemy_cratedb/dialect.py +13 -8
- sqlalchemy_cratedb/support/polyfill.py +4 -1
- sqlalchemy_cratedb/support/util.py +4 -11
- {sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/METADATA +1 -1
- {sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/RECORD +11 -11
- {sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/WHEEL +1 -1
- {sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/LICENSE +0 -0
- {sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/NOTICE +0 -0
- {sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/entry_points.txt +0 -0
- {sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/top_level.txt +0 -0
sqlalchemy_cratedb/compiler.py
CHANGED
@@ -100,13 +100,13 @@ def crate_before_execute(conn, clauseelement, multiparams, params, *args, **kwar
|
|
100
100
|
class CrateDDLCompiler(compiler.DDLCompiler):
|
101
101
|
|
102
102
|
__special_opts_tmpl = {
|
103
|
-
'
|
103
|
+
'PARTITIONED_BY': ' PARTITIONED BY ({0})'
|
104
104
|
}
|
105
105
|
__clustered_opts_tmpl = {
|
106
|
-
'
|
107
|
-
'
|
106
|
+
'NUMBER_OF_SHARDS': ' INTO {0} SHARDS',
|
107
|
+
'CLUSTERED_BY': ' BY ({0})',
|
108
108
|
}
|
109
|
-
__clustered_opt_tmpl = ' CLUSTERED{
|
109
|
+
__clustered_opt_tmpl = ' CLUSTERED{CLUSTERED_BY}{NUMBER_OF_SHARDS}'
|
110
110
|
|
111
111
|
def get_column_specification(self, column, **kwargs):
|
112
112
|
colspec = self.preparer.format_column(column) + " " + \
|
@@ -162,7 +162,7 @@ class CrateDDLCompiler(compiler.DDLCompiler):
|
|
162
162
|
table_opts = []
|
163
163
|
|
164
164
|
opts = dict(
|
165
|
-
(k[len(self.dialect.name) + 1:], v)
|
165
|
+
(k[len(self.dialect.name) + 1:].upper(), v)
|
166
166
|
for k, v, in table.kwargs.items()
|
167
167
|
if k.startswith('%s_' % self.dialect.name)
|
168
168
|
)
|
@@ -225,7 +225,7 @@ class CrateTypeCompiler(compiler.GenericTypeCompiler):
|
|
225
225
|
return 'SHORT'
|
226
226
|
|
227
227
|
def visit_datetime(self, type_, **kw):
|
228
|
-
return
|
228
|
+
return 'TIMESTAMP'
|
229
229
|
|
230
230
|
def visit_date(self, type_, **kw):
|
231
231
|
return 'TIMESTAMP'
|
@@ -245,16 +245,6 @@ class CrateTypeCompiler(compiler.GenericTypeCompiler):
|
|
245
245
|
raise ValueError("FloatVector must be initialized with dimension size")
|
246
246
|
return f"FLOAT_VECTOR({dimensions})"
|
247
247
|
|
248
|
-
def visit_TIMESTAMP(self, type_, **kw):
|
249
|
-
"""
|
250
|
-
Support for `TIMESTAMP WITH|WITHOUT TIME ZONE`.
|
251
|
-
|
252
|
-
From `sqlalchemy.dialects.postgresql.base.PGTypeCompiler`.
|
253
|
-
"""
|
254
|
-
return "TIMESTAMP %s" % (
|
255
|
-
(type_.timezone and "WITH" or "WITHOUT") + " TIME ZONE",
|
256
|
-
)
|
257
|
-
|
258
248
|
|
259
249
|
class CrateCompiler(compiler.SQLCompiler):
|
260
250
|
|
sqlalchemy_cratedb/dialect.py
CHANGED
@@ -32,6 +32,7 @@ from .compiler import (
|
|
32
32
|
CrateDDLCompiler,
|
33
33
|
CrateIdentifierPreparer,
|
34
34
|
)
|
35
|
+
from crate.client.exceptions import TimezoneUnawareException
|
35
36
|
from .sa_version import SA_VERSION, SA_1_4, SA_2_0
|
36
37
|
from .type import FloatVector, ObjectArray, ObjectType
|
37
38
|
|
@@ -39,8 +40,8 @@ TYPES_MAP = {
|
|
39
40
|
"boolean": sqltypes.Boolean,
|
40
41
|
"short": sqltypes.SmallInteger,
|
41
42
|
"smallint": sqltypes.SmallInteger,
|
42
|
-
"timestamp": sqltypes.TIMESTAMP
|
43
|
-
"timestamp with time zone": sqltypes.TIMESTAMP
|
43
|
+
"timestamp": sqltypes.TIMESTAMP,
|
44
|
+
"timestamp with time zone": sqltypes.TIMESTAMP,
|
44
45
|
"object": ObjectType,
|
45
46
|
"integer": sqltypes.Integer,
|
46
47
|
"long": sqltypes.NUMERIC,
|
@@ -61,8 +62,8 @@ try:
|
|
61
62
|
TYPES_MAP["boolean_array"] = ARRAY(sqltypes.Boolean)
|
62
63
|
TYPES_MAP["short_array"] = ARRAY(sqltypes.SmallInteger)
|
63
64
|
TYPES_MAP["smallint_array"] = ARRAY(sqltypes.SmallInteger)
|
64
|
-
TYPES_MAP["timestamp_array"] = ARRAY(sqltypes.TIMESTAMP
|
65
|
-
TYPES_MAP["timestamp with time zone_array"] = ARRAY(sqltypes.TIMESTAMP
|
65
|
+
TYPES_MAP["timestamp_array"] = ARRAY(sqltypes.TIMESTAMP)
|
66
|
+
TYPES_MAP["timestamp with time zone_array"] = ARRAY(sqltypes.TIMESTAMP)
|
66
67
|
TYPES_MAP["long_array"] = ARRAY(sqltypes.NUMERIC)
|
67
68
|
TYPES_MAP["bigint_array"] = ARRAY(sqltypes.NUMERIC)
|
68
69
|
TYPES_MAP["double_array"] = ARRAY(sqltypes.DECIMAL)
|
@@ -113,10 +114,15 @@ class Date(sqltypes.Date):
|
|
113
114
|
|
114
115
|
class DateTime(sqltypes.DateTime):
|
115
116
|
|
117
|
+
TZ_ERROR_MSG = "Timezone aware datetime objects are not supported"
|
118
|
+
|
116
119
|
def bind_processor(self, dialect):
|
117
120
|
def process(value):
|
118
|
-
if
|
119
|
-
|
121
|
+
if value is not None:
|
122
|
+
assert isinstance(value, datetime)
|
123
|
+
if value.tzinfo is not None:
|
124
|
+
raise TimezoneUnawareException(DateTime.TZ_ERROR_MSG)
|
125
|
+
return value.strftime('%Y-%m-%dT%H:%M:%S.%fZ')
|
120
126
|
return value
|
121
127
|
return process
|
122
128
|
|
@@ -146,9 +152,8 @@ class DateTime(sqltypes.DateTime):
|
|
146
152
|
|
147
153
|
|
148
154
|
colspecs = {
|
149
|
-
sqltypes.Date: Date,
|
150
155
|
sqltypes.DateTime: DateTime,
|
151
|
-
sqltypes.
|
156
|
+
sqltypes.Date: Date
|
152
157
|
}
|
153
158
|
|
154
159
|
|
@@ -108,7 +108,10 @@ def refresh_after_dml_engine(engine: sa.engine.Engine):
|
|
108
108
|
):
|
109
109
|
if isinstance(clauseelement, (sa.sql.Insert, sa.sql.Update, sa.sql.Delete)):
|
110
110
|
if not isinstance(clauseelement.table, sa.sql.Join):
|
111
|
-
|
111
|
+
full_table_name = f'"{clauseelement.table.name}"'
|
112
|
+
if clauseelement.table.schema is not None:
|
113
|
+
full_table_name = f'"{clauseelement.table.schema}".' + full_table_name
|
114
|
+
refresh_table(conn, full_table_name)
|
112
115
|
|
113
116
|
sa.event.listen(engine, "after_execute", receive_after_execute)
|
114
117
|
|
@@ -10,21 +10,14 @@ if t.TYPE_CHECKING:
|
|
10
10
|
pass
|
11
11
|
|
12
12
|
|
13
|
-
def refresh_table(connection, target: t.Union[str, "DeclarativeBase"
|
13
|
+
def refresh_table(connection, target: t.Union[str, "DeclarativeBase"]):
|
14
14
|
"""
|
15
15
|
Invoke a `REFRESH TABLE` statement.
|
16
16
|
"""
|
17
|
-
|
18
|
-
|
19
|
-
full_table_name = f'"{target.name}"'
|
20
|
-
if target.schema is not None:
|
21
|
-
full_table_name = f'"{target.schema}".' + full_table_name
|
22
|
-
elif hasattr(target, "__tablename__"):
|
23
|
-
full_table_name = target.__tablename__
|
17
|
+
if hasattr(target, "__tablename__"):
|
18
|
+
sql = f"REFRESH TABLE {target.__tablename__}"
|
24
19
|
else:
|
25
|
-
|
26
|
-
|
27
|
-
sql = f"REFRESH TABLE {full_table_name}"
|
20
|
+
sql = f"REFRESH TABLE {target}"
|
28
21
|
connection.execute(sa.text(sql))
|
29
22
|
|
30
23
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
sqlalchemy_cratedb/__init__.py,sha256=HIsl7K75Yi2Z1rey-LXPiuonRVJ-Qj8TVWKmIk5d8g8,2289
|
2
|
-
sqlalchemy_cratedb/compiler.py,sha256=
|
3
|
-
sqlalchemy_cratedb/dialect.py,sha256=
|
2
|
+
sqlalchemy_cratedb/compiler.py,sha256=ECzlBzegW8Ib1dq-bGKfhZxx7yfQCSj7wi9ozENRd7Y,12974
|
3
|
+
sqlalchemy_cratedb/dialect.py,sha256=LTV4dicnHOdriKifZtnmXivl1RMFmqgj2A0E6uiX8jg,14288
|
4
4
|
sqlalchemy_cratedb/predicate.py,sha256=HT7tHF7PxX71G8m91lqpH732iVQZtO8_NPZUIsllcys,3622
|
5
5
|
sqlalchemy_cratedb/sa_version.py,sha256=NhNA5FUw0Sm5n-fSVo6CTcaioDRovUknFOslX31ir-I,1168
|
6
6
|
sqlalchemy_cratedb/compat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -10,17 +10,17 @@ sqlalchemy_cratedb/compat/core14.py,sha256=xh_wnNkMUD8aE_VFQPnPeXWsPIFzPg0ZjkhfJ
|
|
10
10
|
sqlalchemy_cratedb/compat/core20.py,sha256=QgNEA4z37ldFI4X9HapbTcga7KvsrdMkoMRjxvCJ4tE,15145
|
11
11
|
sqlalchemy_cratedb/support/__init__.py,sha256=AwqsVVRBaoMaTZ0zNjcoY9HbLIQsP1vlu__ANL___vY,450
|
12
12
|
sqlalchemy_cratedb/support/pandas.py,sha256=bEQTPJBvJepM5_GY5Jxewu26Fs6d8AKzizxgO4vw2PA,4357
|
13
|
-
sqlalchemy_cratedb/support/polyfill.py,sha256=
|
14
|
-
sqlalchemy_cratedb/support/util.py,sha256=
|
13
|
+
sqlalchemy_cratedb/support/polyfill.py,sha256=cGAVWkl1DisSuGamvee_Qxjvp_ss9uJGq_mM8nUh0lI,5143
|
14
|
+
sqlalchemy_cratedb/support/util.py,sha256=Ll4ZNZBqtApRkzbTFLxT6MoAfWFBIlXBCZEnyyHLxto,986
|
15
15
|
sqlalchemy_cratedb/type/__init__.py,sha256=8Bp0RKTFAx-3ETOcG4R4wjhL5rarN7tJLfrue7S6mH8,141
|
16
16
|
sqlalchemy_cratedb/type/array.py,sha256=RrHkFoNmTKtk_6md0OtsR7xofRxdk0PbfO-JFfevBJI,4396
|
17
17
|
sqlalchemy_cratedb/type/geo.py,sha256=9wFGxGMxxN-7_qZTlmWialzaPp_zzFj4U-yVqY_deA0,1377
|
18
18
|
sqlalchemy_cratedb/type/object.py,sha256=-bebiW38vor3grD9qsomzJ_z3zRpNMb2XLLto2fFez4,3016
|
19
19
|
sqlalchemy_cratedb/type/vector.py,sha256=5Q2v-RuiNKriSm-EX7tTb1PelqqoBvjDOFDB27Xxk5I,4723
|
20
|
-
sqlalchemy_cratedb-0.38.0.dist-info/LICENSE,sha256=s_w3FXmAYQuatqsgvyYLnGyC_13KOqp3W1DUEXO9RpY,10175
|
21
|
-
sqlalchemy_cratedb-0.38.0.dist-info/METADATA,sha256=
|
22
|
-
sqlalchemy_cratedb-0.38.0.dist-info/NOTICE,sha256=yU9CWOf_XrVU7fpqGgM9tDjppoMyfHHBmFVMiINZk-k,1167
|
23
|
-
sqlalchemy_cratedb-0.38.0.dist-info/WHEEL,sha256=
|
24
|
-
sqlalchemy_cratedb-0.38.0.dist-info/entry_points.txt,sha256=c14wyCG3OeM64_DUbI_vLVUXR3e3GhDyO_PCjo6UQMU,57
|
25
|
-
sqlalchemy_cratedb-0.38.0.dist-info/top_level.txt,sha256=UjjXz0burl_-2MApzLzffHG_2RXm6KljZvoGJHISMPo,19
|
26
|
-
sqlalchemy_cratedb-0.38.0.dist-info/RECORD,,
|
20
|
+
sqlalchemy_cratedb-0.38.0.dev0.dist-info/LICENSE,sha256=s_w3FXmAYQuatqsgvyYLnGyC_13KOqp3W1DUEXO9RpY,10175
|
21
|
+
sqlalchemy_cratedb-0.38.0.dev0.dist-info/METADATA,sha256=trBbdmkXNPx969gGqt2JwR57kzZnwLqbJoWLi0g8eyE,6590
|
22
|
+
sqlalchemy_cratedb-0.38.0.dev0.dist-info/NOTICE,sha256=yU9CWOf_XrVU7fpqGgM9tDjppoMyfHHBmFVMiINZk-k,1167
|
23
|
+
sqlalchemy_cratedb-0.38.0.dev0.dist-info/WHEEL,sha256=cpQTJ5IWu9CdaPViMhC9YzF8gZuS5-vlfoFihTBC86A,91
|
24
|
+
sqlalchemy_cratedb-0.38.0.dev0.dist-info/entry_points.txt,sha256=c14wyCG3OeM64_DUbI_vLVUXR3e3GhDyO_PCjo6UQMU,57
|
25
|
+
sqlalchemy_cratedb-0.38.0.dev0.dist-info/top_level.txt,sha256=UjjXz0burl_-2MApzLzffHG_2RXm6KljZvoGJHISMPo,19
|
26
|
+
sqlalchemy_cratedb-0.38.0.dev0.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/entry_points.txt
RENAMED
File without changes
|
{sqlalchemy_cratedb-0.38.0.dist-info → sqlalchemy_cratedb-0.38.0.dev0.dist-info}/top_level.txt
RENAMED
File without changes
|