ormlambda 3.34.0__tar.gz → 3.34.1__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.
Files changed (159) hide show
  1. {ormlambda-3.34.0 → ormlambda-3.34.1}/PKG-INFO +2 -3
  2. {ormlambda-3.34.0 → ormlambda-3.34.1}/pyproject.toml +1 -1
  3. ormlambda-3.34.1/src/ormlambda/databases/__init__.py +4 -0
  4. ormlambda-3.34.1/src/ormlambda/databases/my_sql/__init__.py +3 -0
  5. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/caster.py +5 -1
  6. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/__init__.py +2 -0
  7. ormlambda-3.34.1/src/ormlambda/databases/my_sql/caster/types/date.py +34 -0
  8. ormlambda-3.34.1/src/ormlambda/databases/my_sql/caster/types/decimal.py +32 -0
  9. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/__init__.py +1 -0
  10. ormlambda-3.34.1/src/ormlambda/databases/my_sql/clauses/drop_table.py +26 -0
  11. {ormlambda-3.34.0/src/ormlambda/dialects/mysql/repository → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/repository.py +5 -0
  12. ormlambda-3.34.1/src/ormlambda/dialects/mysql/__init__.py +8 -0
  13. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/mysql/base.py +1 -2
  14. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/engine/base.py +4 -23
  15. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/repository/interfaces/IRepositoryBase.py +7 -0
  16. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/compiler.py +2 -243
  17. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/ddl.py +4 -18
  18. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/foreign_key.py +0 -18
  19. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/table/table.py +9 -5
  20. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/statements/interfaces/IStatements.py +0 -3
  21. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/statements/statements.py +1 -7
  22. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/util/__init__.py +2 -1
  23. ormlambda-3.34.1/src/ormlambda/util/load_module.py +21 -0
  24. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/util/module_tree/dynamic_module.py +1 -1
  25. ormlambda-3.34.0/src/ormlambda/dialects/mysql/__init__.py +0 -38
  26. ormlambda-3.34.0/src/ormlambda/dialects/mysql/repository/__init__.py +0 -1
  27. {ormlambda-3.34.0 → ormlambda-3.34.1}/AUTHORS +0 -0
  28. {ormlambda-3.34.0 → ormlambda-3.34.1}/LICENSE +0 -0
  29. {ormlambda-3.34.0 → ormlambda-3.34.1}/README.md +0 -0
  30. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/__init__.py +0 -0
  31. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/caster/__init__.py +0 -0
  32. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/caster/base_caster.py +0 -0
  33. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/caster/caster.py +0 -0
  34. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/caster/interfaces/ICaster.py +0 -0
  35. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/caster/interfaces/__init__.py +0 -0
  36. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/__init__.py +0 -0
  37. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/abstract_classes/__init__.py +0 -0
  38. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/abstract_classes/clause_info_converter.py +0 -0
  39. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/abstract_classes/decomposition_query.py +0 -0
  40. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/abstract_classes/non_query_base.py +0 -0
  41. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/abstract_classes/query_base.py +0 -0
  42. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/enums/__init__.py +0 -0
  43. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/enums/condition_types.py +0 -0
  44. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/enums/join_type.py +0 -0
  45. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/errors/__init__.py +0 -0
  46. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/global_checker.py +0 -0
  47. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/interfaces/ICustomAlias.py +0 -0
  48. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/interfaces/IDecompositionQuery.py +0 -0
  49. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/interfaces/IJoinSelector.py +0 -0
  50. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/interfaces/INonQueryCommand.py +0 -0
  51. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/interfaces/IQueryCommand.py +0 -0
  52. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/common/interfaces/__init__.py +0 -0
  53. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/__init__.py +0 -0
  54. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/boolean.py +0 -0
  55. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/bytes.py +0 -0
  56. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/datetime.py +0 -0
  57. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/float.py +0 -0
  58. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/int.py +0 -0
  59. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/iterable.py +0 -0
  60. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/none.py +0 -0
  61. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/point.py +0 -0
  62. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/caster/types/string.py +0 -0
  63. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/ST_AsText.py +0 -0
  64. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/ST_Contains.py +0 -0
  65. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/count.py +0 -0
  66. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/delete.py +0 -0
  67. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/group_by.py +0 -0
  68. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/having.py +0 -0
  69. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/insert.py +0 -0
  70. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/joins.py +0 -0
  71. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/limit.py +0 -0
  72. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/offset.py +0 -0
  73. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/order.py +0 -0
  74. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/update.py +0 -0
  75. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/upsert.py +0 -0
  76. {ormlambda-3.34.0/src/ormlambda/dialects/mysql → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/clauses/where.py +0 -0
  77. {ormlambda-3.34.0/src/ormlambda/dialects/mysql/repository → ormlambda-3.34.1/src/ormlambda/databases/my_sql}/pool_types.py +0 -0
  78. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/__init__.py +0 -0
  79. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/default/__init__.py +0 -0
  80. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/default/base.py +0 -0
  81. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/interface/__init__.py +0 -0
  82. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/interface/dialect.py +0 -0
  83. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/mysql/mysqlconnector.py +0 -0
  84. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/mysql/types.py +0 -0
  85. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/sqlite/__init__.py +0 -0
  86. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/sqlite/base.py +0 -0
  87. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/dialects/sqlite/pysqlite.py +0 -0
  88. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/engine/__init__.py +0 -0
  89. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/engine/create.py +0 -0
  90. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/engine/url.py +0 -0
  91. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/engine/utils.py +0 -0
  92. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/env.py +0 -0
  93. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/errors.py +0 -0
  94. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/model/__init__.py +0 -0
  95. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/model/base_model.py +0 -0
  96. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/repository/__init__.py +0 -0
  97. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/repository/base_repository.py +0 -0
  98. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/repository/interfaces/IDatabaseConnection.py +0 -0
  99. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/repository/interfaces/__init__.py +0 -0
  100. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/repository/response.py +0 -0
  101. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/__init__.py +0 -0
  102. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clause_info/__init__.py +0 -0
  103. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clause_info/aggregate_function_base.py +0 -0
  104. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clause_info/clause_info.py +0 -0
  105. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clause_info/clause_info_context.py +0 -0
  106. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clause_info/interface/IAggregate.py +0 -0
  107. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clause_info/interface/IClauseInfo.py +0 -0
  108. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clause_info/interface/__init__.py +0 -0
  109. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/__init__.py +0 -0
  110. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/alias.py +0 -0
  111. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/count.py +0 -0
  112. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/delete.py +0 -0
  113. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/group_by.py +0 -0
  114. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/having.py +0 -0
  115. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/insert.py +0 -0
  116. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/interfaces/IDelete.py +0 -0
  117. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/interfaces/IInsert.py +0 -0
  118. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/interfaces/ISelect.py +0 -0
  119. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/interfaces/IUpdate.py +0 -0
  120. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/interfaces/IUpsert.py +0 -0
  121. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/interfaces/__init__.py +0 -0
  122. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/join/__init__.py +0 -0
  123. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/join/join_context.py +0 -0
  124. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/joins.py +0 -0
  125. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/limit.py +0 -0
  126. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/offset.py +0 -0
  127. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/order.py +0 -0
  128. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/select.py +0 -0
  129. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/update.py +0 -0
  130. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/upsert.py +0 -0
  131. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/clauses/where.py +0 -0
  132. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/column/__init__.py +0 -0
  133. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/column/column.py +0 -0
  134. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/comparer.py +0 -0
  135. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/elements.py +0 -0
  136. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/functions/__init__.py +0 -0
  137. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/functions/concat.py +0 -0
  138. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/functions/max.py +0 -0
  139. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/functions/min.py +0 -0
  140. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/functions/sum.py +0 -0
  141. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/interfaces/__init__.py +0 -0
  142. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/sqltypes.py +0 -0
  143. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/table/__init__.py +0 -0
  144. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/table/fields.py +0 -0
  145. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/table/table_constructor.py +0 -0
  146. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/type_api.py +0 -0
  147. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/types.py +0 -0
  148. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/sql/visitors.py +0 -0
  149. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/statements/__init__.py +0 -0
  150. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/statements/base_statement.py +0 -0
  151. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/statements/interfaces/__init__.py +0 -0
  152. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/statements/query_builder.py +0 -0
  153. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/statements/types.py +0 -0
  154. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/types/__init__.py +0 -0
  155. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/types/metadata.py +0 -0
  156. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/util/module_tree/__init__.py +0 -0
  157. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/util/module_tree/dfs_traversal.py +0 -0
  158. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/util/plugin_loader.py +0 -0
  159. {ormlambda-3.34.0 → ormlambda-3.34.1}/src/ormlambda/util/typing.py +0 -0
@@ -1,13 +1,12 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.1
2
2
  Name: ormlambda
3
- Version: 3.34.0
3
+ Version: 3.34.1
4
4
  Summary: ORM designed to interact with the database (currently with MySQL) using lambda functions and nested functions
5
5
  Author: p-hzamora
6
6
  Author-email: p.hzamora@icloud.com
7
7
  Requires-Python: >=3.12,<4.0
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3.12
10
- Classifier: Programming Language :: Python :: 3.13
11
10
  Requires-Dist: mysql-connector-python (>=9.0.0,<10.0.0)
12
11
  Requires-Dist: shapely (>=2.0.6,<3.0.0)
13
12
  Description-Content-Type: text/markdown
@@ -3,7 +3,7 @@ line-length = 320
3
3
 
4
4
  [tool.poetry]
5
5
  name = "ormlambda"
6
- version = "3.34.0"
6
+ version = "3.34.1"
7
7
  description = "ORM designed to interact with the database (currently with MySQL) using lambda functions and nested functions"
8
8
  authors = ["p-hzamora <p.hzamora@icloud.com>"]
9
9
  readme = "README.md"
@@ -0,0 +1,4 @@
1
+ from .my_sql import (
2
+ MySQLCaster as MySQLCaster,
3
+ MySQLRepository as MySQLRepository,
4
+ )
@@ -0,0 +1,3 @@
1
+ from mysql.connector import MySQLConnection # noqa: F401
2
+ from .repository import MySQLRepository # noqa: F401
3
+ from .caster import MySQLCaster # noqa: F401
@@ -12,11 +12,13 @@ from .types import (
12
12
  BytesCaster,
13
13
  IterableCaster,
14
14
  BooleanCaster,
15
+ DecimalCaster,
15
16
  )
16
17
 
17
18
  from shapely import Point
18
19
  from types import NoneType
19
- from datetime import datetime
20
+ from datetime import datetime, date
21
+ from decimal import Decimal
20
22
 
21
23
 
22
24
  class MySQLCaster(Caster):
@@ -31,9 +33,11 @@ class MySQLCaster(Caster):
31
33
  Point: PointCaster,
32
34
  NoneType: NoneTypeCaster,
33
35
  datetime: DatetimeCaster,
36
+ date: DatetimeCaster,
34
37
  bytes: BytesCaster,
35
38
  bytearray: BytesCaster,
36
39
  tuple: IterableCaster,
37
40
  list: IterableCaster,
38
41
  bool: BooleanCaster,
42
+ Decimal: DecimalCaster,
39
43
  }
@@ -7,3 +7,5 @@ from .datetime import DatetimeCaster as DatetimeCaster
7
7
  from .bytes import BytesCaster as BytesCaster
8
8
  from .iterable import IterableCaster as IterableCaster
9
9
  from .boolean import BooleanCaster as BooleanCaster
10
+ from .date import DateCaster as DateCaster
11
+ from .decimal import DecimalCaster as DecimalCaster
@@ -0,0 +1,34 @@
1
+ from typing import Optional
2
+ from ormlambda.caster import BaseCaster, Caster
3
+ from datetime import datetime
4
+ from .string import StringCaster
5
+
6
+
7
+ class DateCaster[TType](BaseCaster[datetime, TType]):
8
+ def __init__(self, value: datetime, type_value: TType):
9
+ super().__init__(value, type_value)
10
+
11
+ def wildcard_to_select(self, value: Optional[str] = None) -> str:
12
+ return Caster.PLACEHOLDER if value is None else value
13
+
14
+ def wildcard_to_where(self, value: Optional[str] = None) -> str:
15
+ return Caster.PLACEHOLDER if value is None else value
16
+
17
+ def wildcard_to_insert(self, value: Optional[str] = None) -> str:
18
+ return Caster.PLACEHOLDER if value is None else value
19
+
20
+ @property
21
+ @BaseCaster.return_value_if_exists
22
+ def to_database(self) -> Optional[datetime]:
23
+ return self.value
24
+
25
+ @property
26
+ @BaseCaster.return_value_if_exists
27
+ def from_database(self) -> Optional[datetime]:
28
+ return self.value
29
+
30
+ @property
31
+ @BaseCaster.return_value_if_exists
32
+ def string_data(self) -> Optional[str]:
33
+ datetime_string = self.value.strftime(r"%Y-%m-%d")
34
+ return StringCaster(datetime_string, str).string_data
@@ -0,0 +1,32 @@
1
+ from typing import Optional
2
+ from ormlambda.caster import BaseCaster, Caster
3
+ from decimal import Decimal
4
+
5
+
6
+ class DecimalCaster[TType](BaseCaster[Decimal, TType]):
7
+ def __init__(self, value: Decimal, type_value: TType):
8
+ super().__init__(value, type_value)
9
+
10
+ def wildcard_to_select(self, value: Optional[str] = None) -> str:
11
+ return Caster.PLACEHOLDER if value is None else value
12
+
13
+ def wildcard_to_where(self, value: Optional[str] = None) -> str:
14
+ return Caster.PLACEHOLDER if value is None else value
15
+
16
+ def wildcard_to_insert(self, value: Optional[str] = None) -> str:
17
+ return Caster.PLACEHOLDER if value is None else value
18
+
19
+ @property
20
+ @BaseCaster.return_value_if_exists
21
+ def to_database(self) -> Optional[Decimal]:
22
+ return Decimal(self.value)
23
+
24
+ @property
25
+ @BaseCaster.return_value_if_exists
26
+ def from_database(self) -> Optional[Decimal]:
27
+ return Decimal(self.value)
28
+
29
+ @property
30
+ @BaseCaster.return_value_if_exists
31
+ def string_data(self) -> Optional[str]:
32
+ return str(self.value)
@@ -1,4 +1,5 @@
1
1
  from .delete import DeleteQuery as Delete
2
+ from .drop_table import DropTable as DropTable
2
3
  from .insert import InsertQuery as Insert
3
4
  from .joins import JoinSelector as JoinSelector
4
5
  from .limit import Limit as Limit
@@ -0,0 +1,26 @@
1
+ from __future__ import annotations
2
+ from typing import Literal, override, TYPE_CHECKING
3
+
4
+ if TYPE_CHECKING:
5
+ from mysql.connector import MySQLConnection
6
+
7
+ from ormlambda.repository import BaseRepository
8
+
9
+
10
+ TypeExists = Literal["fail", "replace", "append"]
11
+
12
+
13
+ class DropTable:
14
+ def __init__(self, repository: BaseRepository[MySQLConnection]) -> None:
15
+ self._repository: BaseRepository[MySQLConnection] = repository
16
+
17
+ @override
18
+ def execute(self, name: str = None) -> None:
19
+ query = rf"{self.CLAUSE} {name}"
20
+ self._repository.execute(query)
21
+ return None
22
+
23
+ @property
24
+ @override
25
+ def CLAUSE(self) -> str:
26
+ return "DROP TABLE"
@@ -10,6 +10,7 @@ from mysql.connector.pooling import MySQLConnectionPool # noqa: F401
10
10
  from ormlambda.repository import BaseRepository
11
11
 
12
12
  # Custom libraries
13
+ from .clauses import DropTable
13
14
  from ormlambda.repository.response import Response
14
15
  from ormlambda.caster import Caster
15
16
 
@@ -166,6 +167,10 @@ class MySQLRepository(BaseRepository[MySQLConnectionPool]):
166
167
  cursor.execute(query)
167
168
  return None
168
169
 
170
+ @override
171
+ def drop_table(self, name: str) -> None:
172
+ return DropTable(self).execute(name)
173
+
169
174
  @override
170
175
  def database_exists(self, name: str) -> bool:
171
176
  temp_config = self._pool._cnx_config
@@ -0,0 +1,8 @@
1
+ from . import base
2
+ from . import mysqlconnector
3
+
4
+ # default dialect
5
+ base.dialect = dialect = mysqlconnector.dialect
6
+
7
+
8
+ from .types import * # noqa: F403
@@ -38,8 +38,7 @@ from .types import (
38
38
  )
39
39
  from ormlambda.sql.sqltypes import BLOB
40
40
 
41
- from .caster import MySQLCaster
42
- from .repository import MySQLRepository
41
+ from ormlambda.databases.my_sql import MySQLRepository, MySQLCaster
43
42
 
44
43
 
45
44
  if TYPE_CHECKING:
@@ -1,8 +1,8 @@
1
1
  from __future__ import annotations
2
- from pathlib import Path
3
- from typing import TYPE_CHECKING, BinaryIO, Literal, Optional, TextIO
2
+ from typing import TYPE_CHECKING, Literal
4
3
  from ormlambda.engine import url
5
- from ormlambda.sql.ddl import CreateSchema, DropSchema, CreateBackup
4
+ from ormlambda.sql.ddl import CreateSchema, DropSchema
5
+
6
6
 
7
7
  if TYPE_CHECKING:
8
8
  from ormlambda.dialects import Dialect
@@ -20,7 +20,7 @@ class Engine:
20
20
  if if_exists == "replace":
21
21
  self.drop_schema(schema_name, if_exists)
22
22
 
23
- sql = CreateSchema(schema=schema_name, if_not_exists=if_exists == "append").compile(self.dialect).string
23
+ sql = CreateSchema(schema=schema_name, if_not_exists=if_exists== 'append').compile(self.dialect).string
24
24
  try:
25
25
  self.repository.execute(sql)
26
26
  except Exception:
@@ -56,22 +56,3 @@ class Engine:
56
56
  def set_database(self, name: str) -> None:
57
57
  self.repository.database = name
58
58
  return None
59
-
60
- def create_backup(
61
- self,
62
- output: Optional[str | BinaryIO | TextIO] = None,
63
- compress: bool = False,
64
- backup_dir: str = "backups",
65
- **kw,
66
- ) -> Optional[str | BinaryIO | Path]:
67
- return (
68
- CreateBackup(self.url)
69
- .compile(
70
- self.dialect,
71
- output=output,
72
- compress=compress,
73
- backup_dir=backup_dir,
74
- **kw,
75
- )
76
- .string
77
- )
@@ -9,8 +9,12 @@ from typing import (
9
9
  Sequence,
10
10
  Type,
11
11
  Iterable,
12
+ TYPE_CHECKING,
12
13
  )
13
14
 
15
+ if TYPE_CHECKING:
16
+ from ormlambda.statements.types import TypeExists
17
+
14
18
 
15
19
  type _DBAPICursorDescription = Sequence[
16
20
  tuple[
@@ -138,6 +142,9 @@ class IRepositoryBase(ABC):
138
142
  @abstractmethod
139
143
  def execute(self, query: str) -> None: ...
140
144
 
145
+ @abstractmethod
146
+ def drop_table(self, name: str) -> None: ...
147
+
141
148
  @abstractmethod
142
149
  def table_exists(self, name: str) -> bool: ...
143
150
 
@@ -1,13 +1,6 @@
1
1
  from __future__ import annotations
2
2
  import abc
3
- import datetime
4
- import io
5
- import logging
6
- import os
7
- from pathlib import Path
8
- import subprocess
9
- import sys
10
- from typing import Any, BinaryIO, ClassVar, Optional, TYPE_CHECKING, TextIO, Union
3
+ from typing import Any, ClassVar, Optional, TYPE_CHECKING
11
4
 
12
5
  from ormlambda.sql.ddl import CreateColumn
13
6
  from ormlambda.sql.foreign_key import ForeignKey
@@ -22,13 +15,7 @@ if TYPE_CHECKING:
22
15
  from .visitors import Element
23
16
  from .elements import ClauseElement
24
17
  from ormlambda.dialects import Dialect
25
- from ormlambda.sql.ddl import (
26
- CreateTable,
27
- CreateSchema,
28
- DropSchema,
29
- DropTable,
30
- CreateBackup,
31
- )
18
+ from ormlambda.sql.ddl import CreateTable, CreateSchema, DropSchema
32
19
  from .sqltypes import (
33
20
  INTEGER,
34
21
  SMALLINTEGER,
@@ -75,12 +62,6 @@ if TYPE_CHECKING:
75
62
  )
76
63
 
77
64
 
78
- type customString = Union[str | Path]
79
-
80
- logging.basicConfig(stream=sys.stdout, level=logging.INFO)
81
- log = logging.getLogger(__name__)
82
-
83
-
84
65
  class Compiled:
85
66
  """Represent a compiled SQL or DDL expression.
86
67
 
@@ -268,9 +249,6 @@ class DDLCompiler(Compiled):
268
249
  sql += f"\n){table_options};"
269
250
  return sql
270
251
 
271
- def visit_drop_table(self, drop: DropTable, **kw) -> str:
272
- return "DROP TABLE " + drop.element.__table_name__
273
-
274
252
  def visit_create_column(self, create: CreateColumn, first_pk=False, **kw): # noqa: F821
275
253
  column = create.element
276
254
  return self.get_column_specification(column)
@@ -295,225 +273,6 @@ class DDLCompiler(Compiled):
295
273
  return None
296
274
  return None
297
275
 
298
- #TODOH []: refactor in order to improve clarity
299
- def visit_create_backup(
300
- self,
301
- backup: CreateBackup,
302
- output: Optional[Union[Path | str, BinaryIO, TextIO]] = None,
303
- compress: bool = False,
304
- backup_dir: customString = ".",
305
- **kw,
306
- ) -> Optional[str | BinaryIO | Path]:
307
- """
308
- Create MySQL backup with flexible output options
309
-
310
- Args:
311
- backup: An object containing database connection details (host, user, password, database, port).
312
- output: Output destination:
313
- - None: Auto-generate file path
314
- - str: Custom file path (treated as a path-like object)
315
- - Stream object: Write to stream (io.StringIO, io.BytesIO, sys.stdout, etc.)
316
- compress: Whether to compress the output using gzip.
317
- backup_dir: Directory for auto-generated files if 'output' is None.
318
-
319
- Returns:
320
- - File path (str) if output to file.
321
- - Backup data as bytes (if output to binary stream) or string (if output to text stream).
322
- - None if an error occurs.
323
- """
324
-
325
- host = backup.url.host
326
- user = backup.url.username
327
- password = backup.url.password
328
- database = backup.url.database
329
- port = backup.url.port
330
-
331
- if not database:
332
- log.error("Error: Database name is required for backup.")
333
- return None
334
-
335
- # Build mysqldump command
336
- command = [
337
- "mysqldump",
338
- f"--host={host}",
339
- f"--port={port}",
340
- f"--user={user}",
341
- f"--password={password}",
342
- "--single-transaction",
343
- "--routines",
344
- "--triggers",
345
- "--events",
346
- "--lock-tables=false", # Often used to avoid locking during backup
347
- "--add-drop-table",
348
- "--extended-insert",
349
- database,
350
- ]
351
-
352
- def export_to_stream_internal() -> Optional[io.BytesIO]:
353
- nonlocal command, compress, database
354
- # If streaming, execute mysqldump and capture stdout
355
- log.info(f"Backing up database '{database}' to BytesIO...")
356
-
357
- try:
358
- if compress:
359
- # Start mysqldump process
360
- mysqldump_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
361
-
362
- # Start gzip process, taking input from mysqldump
363
- gzip_process = subprocess.Popen(["gzip", "-c"], stdin=mysqldump_process.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
364
-
365
- # Close mysqldump stdout in parent process - gzip will handle it
366
- mysqldump_process.stdout.close()
367
-
368
- # Wait for gzip to complete (which will also wait for mysqldump)
369
- gzip_stdout, gzip_stderr = gzip_process.communicate()
370
-
371
- # Wait for mysqldump to finish and get its stderr
372
- mysqldump_stderr = mysqldump_process.communicate()[1]
373
-
374
- if mysqldump_process.returncode != 0:
375
- log.error(f"mysqldump error: {mysqldump_stderr.decode().strip()}")
376
- return None
377
- if gzip_process.returncode != 0:
378
- log.error(f"gzip error: {gzip_stderr.decode().strip()}")
379
- return None
380
-
381
- log.info("Backup successful and compressed to BytesIO.")
382
- return io.BytesIO(gzip_stdout)
383
- else:
384
- # Directly capture mysqldump output
385
- process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
386
- stdout, stderr = process.communicate()
387
-
388
- if process.returncode != 0:
389
- log.error(f"mysqldump error: {stderr.decode().strip()}")
390
- return None
391
-
392
- log.info("Backup successful to BytesIO.")
393
- return io.BytesIO(stdout)
394
-
395
- except FileNotFoundError as e:
396
- log.error(f"Error: '{e.filename}' command not found. Please ensure mysqldump (and gzip if compressing) is installed and in your system's PATH.")
397
- return None
398
- except Exception as e:
399
- log.error(f"An unexpected error occurred during streaming backup: {e}")
400
- return None
401
-
402
- def export_to_file_internal(file_path: customString) -> Optional[Path]:
403
- nonlocal command, compress, database
404
-
405
- if isinstance(file_path, str):
406
- file_path = Path(file_path)
407
-
408
- if not file_path.exists():
409
- file_path.parent.mkdir(parents=True, exist_ok=True)
410
- file_path.touch()
411
-
412
- try:
413
- if compress:
414
- # Pipe mysqldump output through gzip to file
415
- with open(file_path, "wb") as output_file:
416
- # Start mysqldump process
417
- mysqldump_process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
418
-
419
- # Start gzip process, taking input from mysqldump and writing to file
420
- gzip_process = subprocess.Popen(["gzip", "-c"], stdin=mysqldump_process.stdout, stdout=output_file, stderr=subprocess.PIPE)
421
-
422
- # Close mysqldump stdout in parent process - gzip will handle it
423
- mysqldump_process.stdout.close()
424
-
425
- # Wait for gzip to complete (which will also wait for mysqldump)
426
- gzip_stdout, gzip_stderr = gzip_process.communicate()
427
-
428
- # Wait for mysqldump to finish and get its stderr
429
- mysqldump_stderr = mysqldump_process.communicate()[1]
430
-
431
- if mysqldump_process.returncode != 0:
432
- log.error(f"mysqldump error: {mysqldump_stderr.decode().strip()}")
433
- return None
434
- if gzip_process.returncode != 0:
435
- log.error(f"gzip error: {gzip_stderr.decode().strip()}")
436
- return None
437
- else:
438
- # Directly redirect mysqldump output to file
439
- with open(file_path, "wb") as output_file:
440
- process = subprocess.Popen(command, stdout=output_file, stderr=subprocess.PIPE)
441
- stdout, stderr = process.communicate()
442
-
443
- if process.returncode != 0:
444
- log.error(f"mysqldump error: {stderr.decode().strip()}")
445
- return None
446
-
447
- log.info(f"Backup completed successfully: {file_path}")
448
- return file_path
449
-
450
- except FileNotFoundError as e:
451
- log.error(f"Error: '{e.filename}' command not found. Please ensure mysqldump (and gzip if compressing) is installed and in your system's PATH.")
452
- return None
453
- except Exception as e:
454
- log.error(f"An unexpected error occurred during file backup: {e}")
455
- return None
456
-
457
- try:
458
- if output is None:
459
- # Auto-generate file path
460
-
461
- backup_dir = Path(backup_dir)
462
- backup_dir.mkdir(exist_ok=True)
463
-
464
- timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
465
- file_extension = "sql.gz" if compress else "sql"
466
- output_filename = f"{database}_backup_{timestamp}.{file_extension}"
467
- output_filepath = os.path.join(backup_dir, output_filename)
468
- return export_to_file_internal(output_filepath)
469
-
470
- elif isinstance(output, (io.BytesIO, io.StringIO)):
471
- # Output to a stream object
472
- stream_result = export_to_stream_internal()
473
- if stream_result:
474
- # Write the content from the internal BytesIO to the provided output stream
475
- if isinstance(output, io.BytesIO):
476
- output.write(stream_result.getvalue())
477
- return stream_result.getvalue() # Return bytes if it was a BytesIO internally
478
- elif isinstance(output, io.StringIO):
479
- # Attempt to decode bytes to string if target is StringIO
480
- try:
481
- decoded_content = stream_result.getvalue().decode("utf-8")
482
- output.write(decoded_content)
483
- return decoded_content
484
- except UnicodeDecodeError:
485
- log.error("Error: Cannot decode byte stream to UTF-8 for StringIO output. Consider setting compress=False or ensuring database encoding is compatible.")
486
- return None
487
- return None
488
-
489
- elif isinstance(output, str | Path):
490
- # Output to a custom file path
491
- return export_to_file_internal(output)
492
-
493
- elif isinstance(output, (BinaryIO, TextIO)): # Handles sys.stdout, open file objects
494
- stream_result = export_to_stream_internal()
495
- if stream_result:
496
- if "b" in getattr(output, "mode", "") or isinstance(output, BinaryIO): # Check if it's a binary stream
497
- output.write(stream_result.getvalue())
498
- return stream_result.getvalue()
499
- else: # Assume text stream
500
- try:
501
- decoded_content = stream_result.getvalue().decode("utf-8")
502
- output.write(decoded_content)
503
- return decoded_content
504
- except UnicodeDecodeError:
505
- log.error("Error: Cannot decode byte stream to UTF-8 for text stream output. Consider setting compress=False or ensuring database encoding is compatible.")
506
- return None
507
- return None
508
-
509
- else:
510
- log.error(f"Unsupported output type: {type(output)}")
511
- return None
512
-
513
- except Exception as e:
514
- log.error(f"An unexpected error occurred: {e}")
515
- return None
516
-
517
276
 
518
277
  class GenericTypeCompiler(TypeCompiler):
519
278
  """Generic type compiler
@@ -3,7 +3,6 @@ from typing import TYPE_CHECKING
3
3
  from .elements import ClauseElement
4
4
 
5
5
  if TYPE_CHECKING:
6
- from ormlambda import URL
7
6
  from ormlambda.dialects.interface.dialect import Dialect
8
7
  from ormlambda import Column
9
8
  from ormlambda import Table
@@ -23,22 +22,16 @@ class BaseDDLElement(ClauseElement):
23
22
  return dialect.ddl_compiler(dialect, self, **kw)
24
23
 
25
24
 
26
- class CreateDropTable:
27
- def __init__(self, element: Table):
28
- self.element = element
29
- self.columns = [CreateColumn(c) for c in element.get_columns()]
30
-
31
-
32
- class CreateTable(CreateDropTable, BaseDDLElement):
25
+ class CreateTable(BaseDDLElement):
33
26
  """
34
27
  Class representing a CREATE TABLE statement.
35
28
  """
36
29
 
37
30
  __visit_name__ = "create_table"
38
31
 
39
-
40
- class DropTable(CreateDropTable, BaseDDLElement):
41
- __visit_name__ = "drop_table"
32
+ def __init__(self, element: Table):
33
+ self.element = element
34
+ self.columns = [CreateColumn(c) for c in element.get_columns()]
42
35
 
43
36
 
44
37
  class CreateColumn[T](BaseDDLElement):
@@ -73,10 +66,3 @@ class SchemaExists(BaseDDLElement):
73
66
 
74
67
  def __init__(self, schema: str):
75
68
  self.schema = schema
76
-
77
-
78
- class CreateBackup(BaseDDLElement):
79
- __visit_name__ = "create_backup"
80
-
81
- def __init__(self, url: URL):
82
- self.url = url
@@ -36,14 +36,6 @@ class ForeignKeyContext(set["ForeignKey"]):
36
36
  class ForeignKey[TLeft: Table, TRight: Table](Element, IQuery):
37
37
  __visit_name__ = "foreign_key"
38
38
 
39
- __slots__ = (
40
- "_tright",
41
- "_relationship",
42
- "_comparer",
43
- "_clause_name",
44
- "_keep_alive",
45
- )
46
-
47
39
  stored_calls: ClassVar[ForeignKeyContext] = ForeignKeyContext()
48
40
 
49
41
  @overload
@@ -157,13 +149,3 @@ class ForeignKey[TLeft: Table, TRight: Table](Element, IQuery):
157
149
  comparer.set_context(context)
158
150
  comparer._dialect = dialect
159
151
  return comparer
160
-
161
- def __hash__(self):
162
- return hash((
163
- self._tleft,
164
- self._tright,
165
- self._clause_name,
166
- ))
167
-
168
- def __eq__(self, other: ForeignKey):
169
- return hash(other) == hash(self)
@@ -5,9 +5,10 @@ import json
5
5
  from ormlambda.sql import Column
6
6
  from ormlambda.sql import ForeignKey
7
7
  from ormlambda.util.module_tree.dfs_traversal import DFSTraversal
8
- from ormlambda.sql.ddl import CreateTable, DropTable
8
+ from ormlambda.sql.ddl import CreateTable
9
9
 
10
10
  if TYPE_CHECKING:
11
+ from ormlambda.statements import BaseStatement
11
12
  from ormlambda.dialects import Dialect
12
13
 
13
14
  from .table_constructor import __init_constructor__
@@ -114,14 +115,17 @@ class Table(metaclass=TableMeta):
114
115
  if name == key:
115
116
  return value
116
117
 
118
+ @classmethod
119
+ def create_table_query(cls, statement: BaseStatement) -> str:
120
+ """It's classmethod because of it does not matter the columns values to create the table"""
121
+ from ormlambda.sql.schema_generator import SchemaGeneratorFactory
122
+
123
+ return SchemaGeneratorFactory.get_generator(statement._dialect).create_table(cls)
124
+
117
125
  @classmethod
118
126
  def create_table(cls, dialect: Dialect) -> str:
119
127
  return CreateTable(cls).compile(dialect).string
120
128
 
121
- @classmethod
122
- def drop_table(cls, dialect:Dialect)->str:
123
- return DropTable(cls).compile(dialect).string
124
-
125
129
  @classmethod
126
130
  def find_dependent_tables(cls) -> tuple["Table", ...]:
127
131
  """Work in progress"""
@@ -37,9 +37,6 @@ class IStatements[T: Table](Element):
37
37
  @abstractmethod
38
38
  def create_table(self, if_exists: TypeExists = "fail") -> None: ...
39
39
 
40
- @abstractmethod
41
- def drop_table(self) -> None: ...
42
-
43
40
  # #TODOL [ ]: We must to implement this mehtod
44
41
  # @abstractmethod
45
42
  # def drop_table(self)->None: ...