dbhydra 2.3.1__tar.gz → 2.3.4__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 (32) hide show
  1. dbhydra-2.3.4/LICENSE +22 -0
  2. {dbhydra-2.3.1 → dbhydra-2.3.4}/PKG-INFO +1 -1
  3. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/dbhydra_core.py +9 -0
  4. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/abstract_db.py +1 -0
  5. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/abstract_table.py +22 -5
  6. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/mysql_db.py +1 -0
  7. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/tables.py +5 -0
  8. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/xlsx_db.py +2 -1
  9. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra.egg-info/PKG-INFO +1 -1
  10. {dbhydra-2.3.1 → dbhydra-2.3.4}/setup.py +1 -1
  11. dbhydra-2.3.1/LICENSE +0 -19
  12. {dbhydra-2.3.1 → dbhydra-2.3.4}/README.md +0 -0
  13. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/__init__.py +0 -0
  14. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/__init__.py +0 -0
  15. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/bigquery_db.py +0 -0
  16. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/errors/__init__.py +0 -0
  17. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/errors/exceptions.py +0 -0
  18. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/migrator.py +0 -0
  19. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/mongo_db.py +0 -0
  20. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/postgres_db.py +0 -0
  21. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/src/sqlserver_db.py +0 -0
  22. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/test_migrator.py +0 -0
  23. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/tests/__init__.py +0 -0
  24. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/tests/test_cases.py +0 -0
  25. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/tests/test_mongo.py +0 -0
  26. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/tests/test_mysql_ddl.py +0 -0
  27. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra/tests/test_sql.py +0 -0
  28. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra.egg-info/SOURCES.txt +0 -0
  29. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra.egg-info/dependency_links.txt +0 -0
  30. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra.egg-info/requires.txt +0 -0
  31. {dbhydra-2.3.1 → dbhydra-2.3.4}/dbhydra.egg-info/top_level.txt +0 -0
  32. {dbhydra-2.3.1 → dbhydra-2.3.4}/setup.cfg +0 -0
dbhydra-2.3.4/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 DovaX
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbhydra
3
- Version: 2.3.1
3
+ Version: 2.3.4
4
4
  Summary: Data science friendly ORM combining Python
5
5
  Home-page: https://github.com/DovaX/dbhydra
6
6
  Author: DovaX
@@ -26,6 +26,15 @@ class Blob(str):
26
26
  """Store BLOBs up to 16MB."""
27
27
  pass
28
28
 
29
+ class LongText(str):
30
+ """Store long text strings (maps to MySQL LONGTEXT)."""
31
+ pass
32
+
33
+
34
+ class LongText(str):
35
+ """Marker type for columns that should be mapped to LONGTEXT in SQL backends."""
36
+ pass
37
+
29
38
 
30
39
  # dataframe - dictionary auxiliary functions
31
40
  def df_to_dict(df, column1, column2):
@@ -59,6 +59,7 @@ class AbstractDb(abc.ABC):
59
59
  'Optional': 'object',
60
60
  'Jsonable': 'Jsonable',
61
61
  'Blob': 'Blob',
62
+ 'LongText': 'LongText',
62
63
  # 'FrozenSet': frozenset,
63
64
  # 'Deque': list,
64
65
  # 'Any': object,
@@ -134,18 +134,32 @@ class AbstractSelectable:
134
134
  return(rows)
135
135
 
136
136
 
137
- def select_all(self, debug_mode = False):
137
+ def select_all(self, debug_mode = False, limit: Optional[int] = None, offset: Optional[int] = None):
138
138
  quote = self.db1.identifier_quote
139
139
  all_cols_query = ""
140
140
  for col in self.columns:
141
141
  all_cols_query = all_cols_query + quote + col + quote + ","
142
142
  if all_cols_query[-1] == ",":
143
143
  all_cols_query = all_cols_query[:-1]
144
- list1 = self.select(f"SELECT {all_cols_query} FROM {quote}{self.name}{quote};", debug_mode = debug_mode)
144
+
145
+ query = f"SELECT {all_cols_query} FROM {quote}{self.name}{quote}"
146
+
147
+ # Add LIMIT and OFFSET to the query
148
+ if limit is not None and limit > 0:
149
+ if offset is not None and offset > 0:
150
+ query += f" LIMIT {offset}, {limit}"
151
+ else:
152
+ query += f" LIMIT {limit}"
153
+ elif offset is not None and offset > 0:
154
+ # MySQL requires LIMIT when using OFFSET, use a large number for all remaining rows
155
+ query += f" LIMIT {offset}, 18446744073709551615"
156
+
157
+ query += ";"
158
+ list1 = self.select(query, debug_mode = debug_mode)
145
159
  return (list1)
146
160
 
147
- def select_to_df(self, debug_mode = False):
148
- rows = self.select_all(debug_mode = debug_mode)
161
+ def select_to_df(self, debug_mode = False, limit: Optional[int] = None, offset: Optional[int] = None):
162
+ rows = self.select_all(debug_mode = debug_mode, limit = limit, offset = offset)
149
163
  if self.query_building_enabled:
150
164
  self.to_df()
151
165
  df=None
@@ -270,7 +284,10 @@ class AbstractTable(AbstractJoinable, abc.ABC):
270
284
  def update(self, variable_assign, where=None, debug_mode = False):
271
285
  quote = self.db1.identifier_quote
272
286
 
273
- query = f"UPDATE {quote}{self.name}{quote} SET {variable_assign}"
287
+ assert "=" in variable_assign
288
+ assigned_variable,assigned_value=variable_assign.split("=").strip()
289
+
290
+ query = f"UPDATE {quote}{self.name}{quote} SET {quote}{assigned_variable}{quote} = {assigned_value}"
274
291
 
275
292
  if where:
276
293
  query += f" WHERE {where}"
@@ -21,6 +21,7 @@ class MysqlDb(AbstractDb):
21
21
  'datetime': "datetime",
22
22
  'Jsonable': "json",
23
23
  'Blob': "mediumblob",
24
+ 'LongText': "longtext",
24
25
  }
25
26
 
26
27
  def __init__(self, *args, **kwargs):
@@ -808,6 +808,11 @@ class MysqlTable(AbstractTable):
808
808
  query += "'" + str(rows[k][j]) + "',"
809
809
  elif "json" in self.types[j + start_index]:
810
810
  query += f"'{rows[k][j]}', "
811
+ elif "text" in self.types[j + start_index]:
812
+ # Covers text, mediumtext, longtext
813
+ if replace_apostrophes:
814
+ rows[k][j] = str(rows[k][j]).replace("'", "")
815
+ query += "'" + str(rows[k][j]) + "',"
811
816
  elif 'blob' in self.types[j + start_index]:
812
817
  # Convert to hex to allow insertion into SQL query
813
818
  hex_data = binascii.hexlify(rows[k][j]).decode('ascii')
@@ -43,7 +43,8 @@ class XlsxDb(AbstractDb):
43
43
  'bool': "bool",
44
44
  'datetime': "datetime",
45
45
  'Jsonable': "str",
46
- 'Blob': "Blob"
46
+ 'Blob': "Blob",
47
+ 'LongText': "str"
47
48
  }
48
49
 
49
50
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbhydra
3
- Version: 2.3.1
3
+ Version: 2.3.4
4
4
  Summary: Data science friendly ORM combining Python
5
5
  Home-page: https://github.com/DovaX/dbhydra
6
6
  Author: DovaX
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name='dbhydra',
8
- version='2.3.1',
8
+ version='2.3.4',
9
9
  author='DovaX',
10
10
  author_email='dovax.ai@gmail.com',
11
11
  description='Data science friendly ORM combining Python',
dbhydra-2.3.1/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2020 The Python Packaging Authority
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to deal
5
- in the Software without restriction, including without limitation the rights
6
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all
11
- copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- SOFTWARE.
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes