velocity-python 0.0.109__py3-none-any.whl → 0.0.155__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.
Files changed (120) hide show
  1. velocity/__init__.py +3 -1
  2. velocity/app/orders.py +3 -4
  3. velocity/app/tests/__init__.py +1 -0
  4. velocity/app/tests/test_email_processing.py +112 -0
  5. velocity/app/tests/test_payment_profile_sorting.py +191 -0
  6. velocity/app/tests/test_spreadsheet_functions.py +124 -0
  7. velocity/aws/__init__.py +3 -0
  8. velocity/aws/amplify.py +10 -6
  9. velocity/aws/handlers/__init__.py +2 -0
  10. velocity/aws/handlers/base_handler.py +248 -0
  11. velocity/aws/handlers/context.py +167 -2
  12. velocity/aws/handlers/exceptions.py +16 -0
  13. velocity/aws/handlers/lambda_handler.py +24 -85
  14. velocity/aws/handlers/mixins/__init__.py +16 -0
  15. velocity/aws/handlers/mixins/activity_tracker.py +181 -0
  16. velocity/aws/handlers/mixins/aws_session_mixin.py +192 -0
  17. velocity/aws/handlers/mixins/error_handler.py +192 -0
  18. velocity/aws/handlers/mixins/legacy_mixin.py +53 -0
  19. velocity/aws/handlers/mixins/standard_mixin.py +73 -0
  20. velocity/aws/handlers/response.py +1 -1
  21. velocity/aws/handlers/sqs_handler.py +28 -143
  22. velocity/aws/tests/__init__.py +1 -0
  23. velocity/aws/tests/test_lambda_handler_json_serialization.py +120 -0
  24. velocity/aws/tests/test_response.py +163 -0
  25. velocity/db/__init__.py +16 -4
  26. velocity/db/core/decorators.py +20 -4
  27. velocity/db/core/engine.py +185 -839
  28. velocity/db/core/result.py +30 -24
  29. velocity/db/core/row.py +15 -3
  30. velocity/db/core/table.py +279 -40
  31. velocity/db/core/transaction.py +19 -11
  32. velocity/db/exceptions.py +42 -18
  33. velocity/db/servers/base/__init__.py +9 -0
  34. velocity/db/servers/base/initializer.py +70 -0
  35. velocity/db/servers/base/operators.py +98 -0
  36. velocity/db/servers/base/sql.py +503 -0
  37. velocity/db/servers/base/types.py +135 -0
  38. velocity/db/servers/mysql/__init__.py +73 -0
  39. velocity/db/servers/mysql/operators.py +54 -0
  40. velocity/db/servers/{mysql_reserved.py → mysql/reserved.py} +2 -14
  41. velocity/db/servers/mysql/sql.py +718 -0
  42. velocity/db/servers/mysql/types.py +107 -0
  43. velocity/db/servers/postgres/__init__.py +59 -11
  44. velocity/db/servers/postgres/operators.py +34 -0
  45. velocity/db/servers/postgres/sql.py +474 -120
  46. velocity/db/servers/postgres/types.py +88 -2
  47. velocity/db/servers/sqlite/__init__.py +61 -0
  48. velocity/db/servers/sqlite/operators.py +52 -0
  49. velocity/db/servers/sqlite/reserved.py +20 -0
  50. velocity/db/servers/sqlite/sql.py +677 -0
  51. velocity/db/servers/sqlite/types.py +92 -0
  52. velocity/db/servers/sqlserver/__init__.py +73 -0
  53. velocity/db/servers/sqlserver/operators.py +47 -0
  54. velocity/db/servers/sqlserver/reserved.py +32 -0
  55. velocity/db/servers/sqlserver/sql.py +805 -0
  56. velocity/db/servers/sqlserver/types.py +114 -0
  57. velocity/db/servers/tablehelper.py +117 -91
  58. velocity/db/tests/__init__.py +1 -0
  59. velocity/db/tests/common_db_test.py +0 -0
  60. velocity/db/tests/postgres/__init__.py +1 -0
  61. velocity/db/tests/postgres/common.py +49 -0
  62. velocity/db/tests/postgres/test_column.py +29 -0
  63. velocity/db/tests/postgres/test_connections.py +25 -0
  64. velocity/db/tests/postgres/test_database.py +21 -0
  65. velocity/db/tests/postgres/test_engine.py +205 -0
  66. velocity/db/tests/postgres/test_general_usage.py +88 -0
  67. velocity/db/tests/postgres/test_imports.py +8 -0
  68. velocity/db/tests/postgres/test_result.py +19 -0
  69. velocity/db/tests/postgres/test_row.py +137 -0
  70. velocity/db/tests/postgres/test_row_comprehensive.py +720 -0
  71. velocity/db/tests/postgres/test_schema_locking.py +335 -0
  72. velocity/db/tests/postgres/test_schema_locking_unit.py +115 -0
  73. velocity/db/tests/postgres/test_sequence.py +34 -0
  74. velocity/db/tests/postgres/test_sql_comprehensive.py +462 -0
  75. velocity/db/tests/postgres/test_table.py +101 -0
  76. velocity/db/tests/postgres/test_table_comprehensive.py +646 -0
  77. velocity/db/tests/postgres/test_transaction.py +106 -0
  78. velocity/db/tests/sql/__init__.py +1 -0
  79. velocity/db/tests/sql/common.py +177 -0
  80. velocity/db/tests/sql/test_postgres_select_advanced.py +285 -0
  81. velocity/db/tests/sql/test_postgres_select_variances.py +517 -0
  82. velocity/db/tests/test_cursor_rowcount_fix.py +150 -0
  83. velocity/db/tests/test_db_utils.py +221 -0
  84. velocity/db/tests/test_postgres.py +448 -0
  85. velocity/db/tests/test_postgres_unchanged.py +81 -0
  86. velocity/db/tests/test_process_error_robustness.py +292 -0
  87. velocity/db/tests/test_result_caching.py +279 -0
  88. velocity/db/tests/test_result_sql_aware.py +117 -0
  89. velocity/db/tests/test_row_get_missing_column.py +72 -0
  90. velocity/db/tests/test_schema_locking_initializers.py +226 -0
  91. velocity/db/tests/test_schema_locking_simple.py +97 -0
  92. velocity/db/tests/test_sql_builder.py +165 -0
  93. velocity/db/tests/test_tablehelper.py +486 -0
  94. velocity/db/utils.py +62 -47
  95. velocity/misc/conv/__init__.py +2 -0
  96. velocity/misc/conv/iconv.py +5 -4
  97. velocity/misc/export.py +1 -4
  98. velocity/misc/merge.py +1 -1
  99. velocity/misc/tests/__init__.py +1 -0
  100. velocity/misc/tests/test_db.py +90 -0
  101. velocity/misc/tests/test_fix.py +78 -0
  102. velocity/misc/tests/test_format.py +64 -0
  103. velocity/misc/tests/test_iconv.py +203 -0
  104. velocity/misc/tests/test_merge.py +82 -0
  105. velocity/misc/tests/test_oconv.py +144 -0
  106. velocity/misc/tests/test_original_error.py +52 -0
  107. velocity/misc/tests/test_timer.py +74 -0
  108. velocity/misc/tools.py +0 -1
  109. {velocity_python-0.0.109.dist-info → velocity_python-0.0.155.dist-info}/METADATA +2 -2
  110. velocity_python-0.0.155.dist-info/RECORD +129 -0
  111. velocity/db/core/exceptions.py +0 -70
  112. velocity/db/servers/mysql.py +0 -641
  113. velocity/db/servers/sqlite.py +0 -968
  114. velocity/db/servers/sqlite_reserved.py +0 -208
  115. velocity/db/servers/sqlserver.py +0 -921
  116. velocity/db/servers/sqlserver_reserved.py +0 -314
  117. velocity_python-0.0.109.dist-info/RECORD +0 -56
  118. {velocity_python-0.0.109.dist-info → velocity_python-0.0.155.dist-info}/WHEEL +0 -0
  119. {velocity_python-0.0.109.dist-info → velocity_python-0.0.155.dist-info}/licenses/LICENSE +0 -0
  120. {velocity_python-0.0.109.dist-info → velocity_python-0.0.155.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,92 @@
1
+ import decimal
2
+ import datetime
3
+ from ..base.types import BaseTypes
4
+
5
+
6
+ class TYPES(BaseTypes):
7
+ """
8
+ SQLite-specific type mapping implementation.
9
+ Note: SQLite has dynamic typing, but we still define these for consistency.
10
+ """
11
+
12
+ TEXT = "TEXT"
13
+ INTEGER = "INTEGER"
14
+ NUMERIC = "NUMERIC"
15
+ REAL = "REAL"
16
+ BLOB = "BLOB"
17
+ # SQLite doesn't have separate date/time types - they're stored as TEXT, REAL, or INTEGER
18
+ DATE = "TEXT"
19
+ TIME = "TEXT"
20
+ DATETIME = "TEXT"
21
+ TIMESTAMP = "TEXT"
22
+ BOOLEAN = "INTEGER" # SQLite stores booleans as integers
23
+
24
+ @classmethod
25
+ def get_type(cls, v):
26
+ """
27
+ Returns a suitable SQL type string for a Python value/object (SQLite).
28
+ """
29
+ is_special, special_val = cls._handle_special_values(v)
30
+ if is_special:
31
+ return special_val
32
+
33
+ if isinstance(v, str) or v is str:
34
+ return cls.TEXT
35
+ if isinstance(v, bool) or v is bool:
36
+ return cls.BOOLEAN
37
+ if isinstance(v, int) or v is int:
38
+ return cls.INTEGER
39
+ if isinstance(v, float) or v is float:
40
+ return cls.REAL
41
+ if isinstance(v, decimal.Decimal) or v is decimal.Decimal:
42
+ return cls.NUMERIC
43
+ if isinstance(v, (datetime.datetime, datetime.date, datetime.time)) or v in (datetime.datetime, datetime.date, datetime.time):
44
+ return cls.TEXT # SQLite stores dates as text
45
+ if isinstance(v, bytes) or v is bytes:
46
+ return cls.BLOB
47
+ return cls.TEXT
48
+
49
+ @classmethod
50
+ def get_conv(cls, v):
51
+ """
52
+ Returns a base SQL type for expression usage (SQLite).
53
+ """
54
+ is_special, special_val = cls._handle_special_values(v)
55
+ if is_special:
56
+ return special_val
57
+
58
+ if isinstance(v, str) or v is str:
59
+ return cls.TEXT
60
+ if isinstance(v, bool) or v is bool:
61
+ return cls.BOOLEAN
62
+ if isinstance(v, int) or v is int:
63
+ return cls.INTEGER
64
+ if isinstance(v, float) or v is float:
65
+ return cls.REAL
66
+ if isinstance(v, decimal.Decimal) or v is decimal.Decimal:
67
+ return cls.NUMERIC
68
+ if isinstance(v, (datetime.datetime, datetime.date, datetime.time)) or v in (datetime.datetime, datetime.date, datetime.time):
69
+ return cls.TEXT
70
+ if isinstance(v, bytes) or v is bytes:
71
+ return cls.BLOB
72
+ return cls.TEXT
73
+
74
+ @classmethod
75
+ def py_type(cls, v):
76
+ """
77
+ Returns the Python type that corresponds to an SQL type string (SQLite).
78
+ """
79
+ v = str(v).upper()
80
+ if v == cls.INTEGER:
81
+ return int
82
+ if v in (cls.NUMERIC, cls.REAL):
83
+ return float # SQLite doesn't distinguish, but float is common
84
+ if v == cls.TEXT:
85
+ return str
86
+ if v == cls.BOOLEAN:
87
+ return bool
88
+ if v == cls.BLOB:
89
+ return bytes
90
+ # For date/time stored as TEXT in SQLite, we'll return str
91
+ # The application layer needs to handle conversion
92
+ return str
@@ -0,0 +1,73 @@
1
+ import os
2
+ from ..base.initializer import BaseInitializer
3
+ from velocity.db.core import engine
4
+ from .sql import SQL
5
+
6
+
7
+ class SQLServerInitializer(BaseInitializer):
8
+ """SQL Server database initializer."""
9
+
10
+ @staticmethod
11
+ def initialize(config=None, schema_locked=False, **kwargs):
12
+ """
13
+ Initialize SQL Server engine with pytds driver.
14
+
15
+ Args:
16
+ config: Configuration dictionary
17
+ schema_locked: Boolean to lock schema modifications
18
+ **kwargs: Additional configuration parameters
19
+
20
+ Returns:
21
+ Configured Engine instance
22
+ """
23
+ try:
24
+ import pytds
25
+ except ImportError:
26
+ raise ImportError(
27
+ "SQL Server connector not available. Install with: pip install python-tds"
28
+ )
29
+
30
+ # Base configuration from environment (if available)
31
+ base_config = {
32
+ "database": os.environ.get("DBDatabase"),
33
+ "server": os.environ.get("DBHost"), # SQL Server uses 'server' instead of 'host'
34
+ "port": os.environ.get("DBPort"),
35
+ "user": os.environ.get("DBUser"),
36
+ "password": os.environ.get("DBPassword"),
37
+ }
38
+
39
+ # Remove None values
40
+ base_config = {k: v for k, v in base_config.items() if v is not None}
41
+
42
+ # Set SQL Server-specific defaults
43
+ sqlserver_defaults = {
44
+ "server": "localhost",
45
+ "port": 1433,
46
+ "autocommit": False,
47
+ "timeout": 30,
48
+ }
49
+
50
+ # Merge configurations: defaults < env < config < kwargs
51
+ final_config = sqlserver_defaults.copy()
52
+ final_config.update(base_config)
53
+ final_config = SQLServerInitializer._merge_config(final_config, config, **kwargs)
54
+
55
+ # Validate required configuration
56
+ required_keys = ["database", "server", "user"]
57
+ SQLServerInitializer._validate_required_config(final_config, required_keys)
58
+
59
+ # Check for environment variable override for schema locking
60
+ if os.environ.get("VELOCITY_SCHEMA_LOCKED", "").lower() in ('true', '1', 'yes'):
61
+ schema_locked = True
62
+
63
+ return engine.Engine(pytds, final_config, SQL, schema_locked=schema_locked)
64
+
65
+
66
+ # Maintain backward compatibility
67
+ def initialize(config=None, schema_locked=False, **kwargs):
68
+ """Backward compatible initialization function."""
69
+ # Check for environment variable override for schema locking
70
+ if os.environ.get("VELOCITY_SCHEMA_LOCKED", "").lower() in ('true', '1', 'yes'):
71
+ schema_locked = True
72
+
73
+ return SQLServerInitializer.initialize(config, schema_locked, **kwargs)
@@ -0,0 +1,47 @@
1
+ from ..base.operators import BaseOperators
2
+
3
+
4
+ class SQLServerOperators(BaseOperators):
5
+ """
6
+ SQL Server-specific operator mappings.
7
+ """
8
+
9
+ @classmethod
10
+ def get_operators(cls):
11
+ """Returns SQL Server-specific operator mappings."""
12
+ return OPERATORS
13
+
14
+ @classmethod
15
+ def supports_case_insensitive_like(cls):
16
+ """SQL Server LIKE case sensitivity depends on collation."""
17
+ return False # Depends on database collation
18
+
19
+ @classmethod
20
+ def supports_regex(cls):
21
+ """SQL Server doesn't have built-in regex operators (until recent versions)."""
22
+ return False
23
+
24
+ @classmethod
25
+ def get_regex_operators(cls):
26
+ """Returns SQL Server regex operators (none in older versions)."""
27
+ return {}
28
+
29
+
30
+ OPERATORS = {
31
+ "<>": "<>",
32
+ "!=": "<>",
33
+ "!><": "NOT BETWEEN",
34
+ ">!<": "NOT BETWEEN",
35
+ "><": "BETWEEN",
36
+ "%%": "LIKE", # SQL Server doesn't have ILIKE
37
+ "!%%": "NOT LIKE",
38
+ "==": "=",
39
+ "<=": "<=",
40
+ ">=": ">=",
41
+ "<": "<",
42
+ ">": ">",
43
+ "%": "LIKE",
44
+ "!%": "NOT LIKE",
45
+ "=": "=",
46
+ "!": "<>",
47
+ }
@@ -0,0 +1,32 @@
1
+ reserved_words = [
2
+ "ADD", "ALL", "ALTER", "AND", "ANY", "AS", "ASC", "AUTHORIZATION",
3
+ "BACKUP", "BEGIN", "BETWEEN", "BREAK", "BROWSE", "BULK", "BY",
4
+ "CASCADE", "CASE", "CHECK", "CHECKPOINT", "CLOSE", "CLUSTERED",
5
+ "COALESCE", "COLLATE", "COLUMN", "COMMIT", "COMPUTE", "CONSTRAINT",
6
+ "CONTAINS", "CONTAINSTABLE", "CONTINUE", "CONVERT", "CREATE", "CROSS",
7
+ "CURRENT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP",
8
+ "CURRENT_USER", "CURSOR", "DATABASE", "DBCC", "DEALLOCATE", "DECLARE",
9
+ "DEFAULT", "DELETE", "DENY", "DESC", "DISK", "DISTINCT", "DISTRIBUTED",
10
+ "DOUBLE", "DROP", "DUMP", "ELSE", "END", "ERRLVL", "ESCAPE", "EXCEPT",
11
+ "EXEC", "EXECUTE", "EXISTS", "EXIT", "EXTERNAL", "FETCH", "FILE",
12
+ "FILLFACTOR", "FOR", "FOREIGN", "FREETEXT", "FREETEXTTABLE", "FROM",
13
+ "FULL", "FUNCTION", "GOTO", "GRANT", "GROUP", "HAVING", "HOLDLOCK",
14
+ "IDENTITY", "IDENTITY_INSERT", "IDENTITYCOL", "IF", "IN", "INDEX",
15
+ "INNER", "INSERT", "INTERSECT", "INTO", "IS", "JOIN", "KEY", "KILL",
16
+ "LEFT", "LIKE", "LINENO", "LOAD", "MERGE", "NATIONAL", "NOCHECK",
17
+ "NONCLUSTERED", "NOT", "NULL", "NULLIF", "OF", "OFF", "OFFSETS",
18
+ "ON", "OPEN", "OPENDATASOURCE", "OPENQUERY", "OPENROWSET", "OPENXML",
19
+ "OPTION", "OR", "ORDER", "OUTER", "OVER", "PERCENT", "PIVOT", "PLAN",
20
+ "PRECISION", "PRIMARY", "PRINT", "PROC", "PROCEDURE", "PUBLIC",
21
+ "RAISERROR", "READ", "READTEXT", "RECONFIGURE", "REFERENCES",
22
+ "REPLICATION", "RESTORE", "RESTRICT", "RETURN", "REVERT", "REVOKE",
23
+ "RIGHT", "ROLLBACK", "ROWCOUNT", "ROWGUIDCOL", "RULE", "SAVE",
24
+ "SCHEMA", "SECURITYAUDIT", "SELECT", "SEMANTICKEYPHRASETABLE",
25
+ "SEMANTICSIMILARITYDETAILSTABLE", "SEMANTICSIMILARITYTABLE",
26
+ "SESSION_USER", "SET", "SETUSER", "SHUTDOWN", "SOME", "STATISTICS",
27
+ "SYSTEM_USER", "TABLE", "TABLESAMPLE", "TEXTSIZE", "THEN", "TO",
28
+ "TOP", "TRAN", "TRANSACTION", "TRIGGER", "TRUNCATE", "TRY_CONVERT",
29
+ "TSEQUAL", "UNION", "UNIQUE", "UNPIVOT", "UPDATE", "UPDATETEXT",
30
+ "USE", "USER", "VALUES", "VARYING", "VIEW", "WAITFOR", "WHEN",
31
+ "WHERE", "WHILE", "WITH", "WITHIN", "WRITETEXT"
32
+ ]