velocity-python 0.0.109__py3-none-any.whl → 0.0.161__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.
- velocity/__init__.py +3 -1
- velocity/app/orders.py +3 -4
- velocity/app/tests/__init__.py +1 -0
- velocity/app/tests/test_email_processing.py +112 -0
- velocity/app/tests/test_payment_profile_sorting.py +191 -0
- velocity/app/tests/test_spreadsheet_functions.py +124 -0
- velocity/aws/__init__.py +3 -0
- velocity/aws/amplify.py +10 -6
- velocity/aws/handlers/__init__.py +2 -0
- velocity/aws/handlers/base_handler.py +248 -0
- velocity/aws/handlers/context.py +251 -2
- velocity/aws/handlers/exceptions.py +16 -0
- velocity/aws/handlers/lambda_handler.py +24 -85
- velocity/aws/handlers/mixins/__init__.py +16 -0
- velocity/aws/handlers/mixins/activity_tracker.py +181 -0
- velocity/aws/handlers/mixins/aws_session_mixin.py +192 -0
- velocity/aws/handlers/mixins/error_handler.py +192 -0
- velocity/aws/handlers/mixins/legacy_mixin.py +53 -0
- velocity/aws/handlers/mixins/standard_mixin.py +73 -0
- velocity/aws/handlers/response.py +1 -1
- velocity/aws/handlers/sqs_handler.py +28 -143
- velocity/aws/tests/__init__.py +1 -0
- velocity/aws/tests/test_lambda_handler_json_serialization.py +120 -0
- velocity/aws/tests/test_response.py +163 -0
- velocity/db/__init__.py +16 -4
- velocity/db/core/decorators.py +48 -13
- velocity/db/core/engine.py +187 -840
- velocity/db/core/result.py +33 -25
- velocity/db/core/row.py +15 -3
- velocity/db/core/table.py +493 -50
- velocity/db/core/transaction.py +28 -15
- velocity/db/exceptions.py +42 -18
- velocity/db/servers/base/__init__.py +9 -0
- velocity/db/servers/base/initializer.py +70 -0
- velocity/db/servers/base/operators.py +98 -0
- velocity/db/servers/base/sql.py +503 -0
- velocity/db/servers/base/types.py +135 -0
- velocity/db/servers/mysql/__init__.py +73 -0
- velocity/db/servers/mysql/operators.py +54 -0
- velocity/db/servers/{mysql_reserved.py → mysql/reserved.py} +2 -14
- velocity/db/servers/mysql/sql.py +718 -0
- velocity/db/servers/mysql/types.py +107 -0
- velocity/db/servers/postgres/__init__.py +59 -11
- velocity/db/servers/postgres/operators.py +34 -0
- velocity/db/servers/postgres/sql.py +474 -120
- velocity/db/servers/postgres/types.py +88 -2
- velocity/db/servers/sqlite/__init__.py +61 -0
- velocity/db/servers/sqlite/operators.py +52 -0
- velocity/db/servers/sqlite/reserved.py +20 -0
- velocity/db/servers/sqlite/sql.py +677 -0
- velocity/db/servers/sqlite/types.py +92 -0
- velocity/db/servers/sqlserver/__init__.py +73 -0
- velocity/db/servers/sqlserver/operators.py +47 -0
- velocity/db/servers/sqlserver/reserved.py +32 -0
- velocity/db/servers/sqlserver/sql.py +805 -0
- velocity/db/servers/sqlserver/types.py +114 -0
- velocity/db/servers/tablehelper.py +117 -91
- velocity/db/tests/__init__.py +1 -0
- velocity/db/tests/common_db_test.py +0 -0
- velocity/db/tests/postgres/__init__.py +1 -0
- velocity/db/tests/postgres/common.py +49 -0
- velocity/db/tests/postgres/test_column.py +29 -0
- velocity/db/tests/postgres/test_connections.py +25 -0
- velocity/db/tests/postgres/test_database.py +21 -0
- velocity/db/tests/postgres/test_engine.py +205 -0
- velocity/db/tests/postgres/test_general_usage.py +88 -0
- velocity/db/tests/postgres/test_imports.py +8 -0
- velocity/db/tests/postgres/test_result.py +19 -0
- velocity/db/tests/postgres/test_row.py +137 -0
- velocity/db/tests/postgres/test_row_comprehensive.py +720 -0
- velocity/db/tests/postgres/test_schema_locking.py +335 -0
- velocity/db/tests/postgres/test_schema_locking_unit.py +115 -0
- velocity/db/tests/postgres/test_sequence.py +34 -0
- velocity/db/tests/postgres/test_sql_comprehensive.py +462 -0
- velocity/db/tests/postgres/test_table.py +101 -0
- velocity/db/tests/postgres/test_table_comprehensive.py +646 -0
- velocity/db/tests/postgres/test_transaction.py +106 -0
- velocity/db/tests/sql/__init__.py +1 -0
- velocity/db/tests/sql/common.py +177 -0
- velocity/db/tests/sql/test_postgres_select_advanced.py +285 -0
- velocity/db/tests/sql/test_postgres_select_variances.py +517 -0
- velocity/db/tests/test_cursor_rowcount_fix.py +150 -0
- velocity/db/tests/test_db_utils.py +270 -0
- velocity/db/tests/test_postgres.py +448 -0
- velocity/db/tests/test_postgres_unchanged.py +81 -0
- velocity/db/tests/test_process_error_robustness.py +292 -0
- velocity/db/tests/test_result_caching.py +279 -0
- velocity/db/tests/test_result_sql_aware.py +117 -0
- velocity/db/tests/test_row_get_missing_column.py +72 -0
- velocity/db/tests/test_schema_locking_initializers.py +226 -0
- velocity/db/tests/test_schema_locking_simple.py +97 -0
- velocity/db/tests/test_sql_builder.py +165 -0
- velocity/db/tests/test_tablehelper.py +486 -0
- velocity/db/utils.py +129 -51
- velocity/misc/conv/__init__.py +2 -0
- velocity/misc/conv/iconv.py +5 -4
- velocity/misc/export.py +1 -4
- velocity/misc/merge.py +1 -1
- velocity/misc/tests/__init__.py +1 -0
- velocity/misc/tests/test_db.py +90 -0
- velocity/misc/tests/test_fix.py +78 -0
- velocity/misc/tests/test_format.py +64 -0
- velocity/misc/tests/test_iconv.py +203 -0
- velocity/misc/tests/test_merge.py +82 -0
- velocity/misc/tests/test_oconv.py +144 -0
- velocity/misc/tests/test_original_error.py +52 -0
- velocity/misc/tests/test_timer.py +74 -0
- velocity/misc/tools.py +0 -1
- {velocity_python-0.0.109.dist-info → velocity_python-0.0.161.dist-info}/METADATA +2 -2
- velocity_python-0.0.161.dist-info/RECORD +129 -0
- velocity/db/core/exceptions.py +0 -70
- velocity/db/servers/mysql.py +0 -641
- velocity/db/servers/sqlite.py +0 -968
- velocity/db/servers/sqlite_reserved.py +0 -208
- velocity/db/servers/sqlserver.py +0 -921
- velocity/db/servers/sqlserver_reserved.py +0 -314
- velocity_python-0.0.109.dist-info/RECORD +0 -56
- {velocity_python-0.0.109.dist-info → velocity_python-0.0.161.dist-info}/WHEEL +0 -0
- {velocity_python-0.0.109.dist-info → velocity_python-0.0.161.dist-info}/licenses/LICENSE +0 -0
- {velocity_python-0.0.109.dist-info → velocity_python-0.0.161.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import decimal
|
|
2
|
+
import datetime
|
|
3
|
+
from ..base.types import BaseTypes
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TYPES(BaseTypes):
|
|
7
|
+
"""
|
|
8
|
+
MySQL-specific type mapping implementation.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
TEXT = "TEXT"
|
|
12
|
+
INTEGER = "INTEGER"
|
|
13
|
+
NUMERIC = "DECIMAL"
|
|
14
|
+
DATETIME = "DATETIME"
|
|
15
|
+
TIMESTAMP = "TIMESTAMP"
|
|
16
|
+
DATE = "DATE"
|
|
17
|
+
TIME = "TIME"
|
|
18
|
+
BIGINT = "BIGINT"
|
|
19
|
+
SMALLINT = "SMALLINT"
|
|
20
|
+
TINYINT = "TINYINT"
|
|
21
|
+
BOOLEAN = "BOOLEAN"
|
|
22
|
+
BINARY = "BLOB"
|
|
23
|
+
LONGTEXT = "LONGTEXT"
|
|
24
|
+
MEDIUMTEXT = "MEDIUMTEXT"
|
|
25
|
+
VARCHAR = "VARCHAR"
|
|
26
|
+
|
|
27
|
+
@classmethod
|
|
28
|
+
def get_type(cls, v):
|
|
29
|
+
"""
|
|
30
|
+
Returns a suitable SQL type string for a Python value/object (MySQL).
|
|
31
|
+
"""
|
|
32
|
+
is_special, special_val = cls._handle_special_values(v)
|
|
33
|
+
if is_special:
|
|
34
|
+
return special_val
|
|
35
|
+
|
|
36
|
+
if isinstance(v, str) or v is str:
|
|
37
|
+
return cls.TEXT
|
|
38
|
+
if isinstance(v, bool) or v is bool:
|
|
39
|
+
return cls.BOOLEAN
|
|
40
|
+
if isinstance(v, int) or v is int:
|
|
41
|
+
return cls.BIGINT
|
|
42
|
+
if isinstance(v, float) or v is float:
|
|
43
|
+
return f"{cls.NUMERIC}(19, 6)"
|
|
44
|
+
if isinstance(v, decimal.Decimal) or v is decimal.Decimal:
|
|
45
|
+
return f"{cls.NUMERIC}(19, 6)"
|
|
46
|
+
if isinstance(v, datetime.datetime) or v is datetime.datetime:
|
|
47
|
+
return cls.DATETIME
|
|
48
|
+
if isinstance(v, datetime.date) or v is datetime.date:
|
|
49
|
+
return cls.DATE
|
|
50
|
+
if isinstance(v, datetime.time) or v is datetime.time:
|
|
51
|
+
return cls.TIME
|
|
52
|
+
if isinstance(v, bytes) or v is bytes:
|
|
53
|
+
return cls.BINARY
|
|
54
|
+
return cls.TEXT
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def get_conv(cls, v):
|
|
58
|
+
"""
|
|
59
|
+
Returns a base SQL type for expression usage (MySQL).
|
|
60
|
+
"""
|
|
61
|
+
is_special, special_val = cls._handle_special_values(v)
|
|
62
|
+
if is_special:
|
|
63
|
+
return special_val
|
|
64
|
+
|
|
65
|
+
if isinstance(v, str) or v is str:
|
|
66
|
+
return cls.TEXT
|
|
67
|
+
if isinstance(v, bool) or v is bool:
|
|
68
|
+
return cls.BOOLEAN
|
|
69
|
+
if isinstance(v, int) or v is int:
|
|
70
|
+
return cls.BIGINT
|
|
71
|
+
if isinstance(v, float) or v is float:
|
|
72
|
+
return cls.NUMERIC
|
|
73
|
+
if isinstance(v, decimal.Decimal) or v is decimal.Decimal:
|
|
74
|
+
return cls.NUMERIC
|
|
75
|
+
if isinstance(v, datetime.datetime) or v is datetime.datetime:
|
|
76
|
+
return cls.DATETIME
|
|
77
|
+
if isinstance(v, datetime.date) or v is datetime.date:
|
|
78
|
+
return cls.DATE
|
|
79
|
+
if isinstance(v, datetime.time) or v is datetime.time:
|
|
80
|
+
return cls.TIME
|
|
81
|
+
if isinstance(v, bytes) or v is bytes:
|
|
82
|
+
return cls.BINARY
|
|
83
|
+
return cls.TEXT
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
def py_type(cls, v):
|
|
87
|
+
"""
|
|
88
|
+
Returns the Python type that corresponds to an SQL type string (MySQL).
|
|
89
|
+
"""
|
|
90
|
+
v = str(v).upper()
|
|
91
|
+
if v in (cls.INTEGER, cls.SMALLINT, cls.BIGINT, cls.TINYINT):
|
|
92
|
+
return int
|
|
93
|
+
if v == cls.NUMERIC or "DECIMAL" in v:
|
|
94
|
+
return decimal.Decimal
|
|
95
|
+
if v in (cls.TEXT, cls.LONGTEXT, cls.MEDIUMTEXT, cls.VARCHAR) or "VARCHAR" in v or "CHAR" in v:
|
|
96
|
+
return str
|
|
97
|
+
if v == cls.BOOLEAN:
|
|
98
|
+
return bool
|
|
99
|
+
if v == cls.DATE:
|
|
100
|
+
return datetime.date
|
|
101
|
+
if v == cls.TIME:
|
|
102
|
+
return datetime.time
|
|
103
|
+
if v in (cls.DATETIME, cls.TIMESTAMP):
|
|
104
|
+
return datetime.datetime
|
|
105
|
+
if v == cls.BINARY or "BLOB" in v:
|
|
106
|
+
return bytes
|
|
107
|
+
raise Exception(f"Unmapped MySQL type {v}")
|
|
@@ -1,19 +1,67 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import psycopg2
|
|
3
3
|
from .sql import SQL
|
|
4
|
+
from ..base.initializer import BaseInitializer
|
|
4
5
|
from velocity.db.core import engine
|
|
5
6
|
|
|
6
7
|
|
|
8
|
+
class PostgreSQLInitializer(BaseInitializer):
|
|
9
|
+
"""PostgreSQL database initializer."""
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
@staticmethod
|
|
12
|
+
def initialize(config=None, schema_locked=False, **kwargs):
|
|
13
|
+
"""
|
|
14
|
+
Initialize PostgreSQL engine with psycopg2 driver.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
config: Configuration dictionary
|
|
18
|
+
schema_locked: Boolean to lock schema modifications
|
|
19
|
+
**kwargs: Additional configuration parameters
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
Configured Engine instance
|
|
23
|
+
"""
|
|
24
|
+
# Base configuration from environment
|
|
25
|
+
base_config = {
|
|
26
|
+
"database": os.environ.get("DBDatabase"),
|
|
27
|
+
"host": os.environ.get("DBHost"),
|
|
28
|
+
"port": os.environ.get("DBPort"),
|
|
29
|
+
"user": os.environ.get("DBUser"),
|
|
30
|
+
"password": os.environ.get("DBPassword"),
|
|
17
31
|
}
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
|
|
33
|
+
# Remove None values
|
|
34
|
+
base_config = {k: v for k, v in base_config.items() if v is not None}
|
|
35
|
+
|
|
36
|
+
# Merge configurations
|
|
37
|
+
final_config = PostgreSQLInitializer._merge_config(base_config, config, **kwargs)
|
|
38
|
+
|
|
39
|
+
# Validate required configuration
|
|
40
|
+
required_keys = ["database", "host", "user", "password"]
|
|
41
|
+
PostgreSQLInitializer._validate_required_config(final_config, required_keys)
|
|
42
|
+
|
|
43
|
+
# Check for environment variable override for schema locking
|
|
44
|
+
if os.environ.get("VELOCITY_SCHEMA_LOCKED", "").lower() in ('true', '1', 'yes'):
|
|
45
|
+
schema_locked = True
|
|
46
|
+
|
|
47
|
+
return engine.Engine(psycopg2, final_config, SQL, schema_locked=schema_locked)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# Maintain backward compatibility
|
|
51
|
+
def initialize(config=None, schema_locked=False, **kwargs):
|
|
52
|
+
"""Backward compatible initialization function - matches original behavior exactly."""
|
|
53
|
+
konfig = {
|
|
54
|
+
"database": os.environ["DBDatabase"],
|
|
55
|
+
"host": os.environ["DBHost"],
|
|
56
|
+
"port": os.environ["DBPort"],
|
|
57
|
+
"user": os.environ["DBUser"],
|
|
58
|
+
"password": os.environ["DBPassword"],
|
|
59
|
+
}
|
|
60
|
+
konfig.update(config or {})
|
|
61
|
+
konfig.update(kwargs)
|
|
62
|
+
|
|
63
|
+
# Check for environment variable override for schema locking
|
|
64
|
+
if os.environ.get("VELOCITY_SCHEMA_LOCKED", "").lower() in ('true', '1', 'yes'):
|
|
65
|
+
schema_locked = True
|
|
66
|
+
|
|
67
|
+
return engine.Engine(psycopg2, konfig, SQL, schema_locked=schema_locked)
|
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
from ..base.operators import BaseOperators
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class PostgreSQLOperators(BaseOperators):
|
|
5
|
+
"""
|
|
6
|
+
PostgreSQL-specific operator mappings.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
@classmethod
|
|
10
|
+
def get_operators(cls):
|
|
11
|
+
"""Returns PostgreSQL-specific operator mappings."""
|
|
12
|
+
return OPERATORS
|
|
13
|
+
|
|
14
|
+
@classmethod
|
|
15
|
+
def supports_case_insensitive_like(cls):
|
|
16
|
+
"""PostgreSQL supports ILIKE for case-insensitive matching."""
|
|
17
|
+
return True
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def supports_regex(cls):
|
|
21
|
+
"""PostgreSQL supports regex operators."""
|
|
22
|
+
return True
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def get_regex_operators(cls):
|
|
26
|
+
"""Returns PostgreSQL regex operators."""
|
|
27
|
+
return {
|
|
28
|
+
"~": "~",
|
|
29
|
+
"!~": "!~",
|
|
30
|
+
"~*": "~*",
|
|
31
|
+
"!~*": "!~*",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
1
35
|
OPERATORS = {
|
|
2
36
|
"<>": "<>",
|
|
3
37
|
"!=": "<>",
|