tina4-python 0.2.44__tar.gz → 0.2.46__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 (42) hide show
  1. {tina4_python-0.2.44 → tina4_python-0.2.46}/PKG-INFO +1 -1
  2. {tina4_python-0.2.44 → tina4_python-0.2.46}/pyproject.toml +1 -1
  3. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Database.py +43 -38
  4. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Debug.py +1 -1
  5. {tina4_python-0.2.44 → tina4_python-0.2.46}/README.md +0 -0
  6. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Auth.py +0 -0
  7. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Constant.py +0 -0
  8. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/DatabaseResult.py +0 -0
  9. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Env.py +0 -0
  10. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Localization.py +0 -0
  11. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Messages.py +0 -0
  12. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/MiddleWare.py +0 -0
  13. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Migration.py +0 -0
  14. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/ORM.py +0 -0
  15. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Queue.py +0 -0
  16. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Request.py +0 -0
  17. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Response.py +0 -0
  18. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Router.py +0 -0
  19. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Session.py +0 -0
  20. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/ShellColors.py +0 -0
  21. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Swagger.py +0 -0
  22. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Template.py +0 -0
  23. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/Webserver.py +0 -0
  24. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/__init__.py +0 -0
  25. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/messages.pot +0 -0
  26. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/css/readme.md +0 -0
  27. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/favicon.ico +0 -0
  28. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/images/403.png +0 -0
  29. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/images/404.png +0 -0
  30. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/images/logo.png +0 -0
  31. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/images/readme.md +0 -0
  32. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/js/readme.md +0 -0
  33. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/js/tina4helper.js +0 -0
  34. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/swagger/index.html +0 -0
  35. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/public/swagger/oauth2-redirect.html +0 -0
  36. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/templates/errors/403.twig +0 -0
  37. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/templates/errors/404.twig +0 -0
  38. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/templates/readme.md +0 -0
  39. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/translations/en/LC_MESSAGES/messages.mo +0 -0
  40. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/translations/en/LC_MESSAGES/messages.po +0 -0
  41. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/translations/fr/LC_MESSAGES/messages.mo +0 -0
  42. {tina4_python-0.2.44 → tina4_python-0.2.46}/tina4_python/translations/fr/LC_MESSAGES/messages.po +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tina4-python
3
- Version: 0.2.44
3
+ Version: 0.2.46
4
4
  Summary: Tina4Python - This is not another framework for Python
5
5
  Author: Andre van Zuydam
6
6
  Author-email: andrevanzuydam@gmail.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "tina4-python"
3
- version = "0.2.44"
3
+ version = "0.2.46"
4
4
  description = "Tina4Python - This is not another framework for Python"
5
5
  authors = ["Andre van Zuydam <andrevanzuydam@gmail.com>"]
6
6
  readme = "README.md"
@@ -133,8 +133,8 @@ class Database:
133
133
  def table_exists(self, table_name):
134
134
  """
135
135
  Checks if a table exists in the database
136
- :param table_name:
137
- :return:
136
+ :param str table_name: Name of the table
137
+ :return: bool : True if table exists, else False
138
138
  """
139
139
 
140
140
  sql = ""
@@ -163,10 +163,10 @@ class Database:
163
163
 
164
164
  def get_next_id(self, table_name, column_name="id"):
165
165
  """
166
- Gets the next id using max method in sql
167
- :param table_name:
168
- :param column_name:
169
- :return:
166
+ Gets the next id using max method in sql for databases which don't have good sequences
167
+ :param str table_name: Name of the table
168
+ :param str column_name: Name of the column in that table to increment
169
+ :return: int : The next id in the sequence
170
170
  """
171
171
  try:
172
172
  sql = "select max(" + column_name + ") as \"max_id\" from " + table_name
@@ -223,11 +223,11 @@ class Database:
223
223
  def fetch(self, sql, params=[], limit=10, skip=0):
224
224
  """
225
225
  Fetch records based on a sql statement
226
- :param sql:
227
- :param params:
228
- :param limit:
229
- :param skip:
230
- :return:
226
+ :param str sql: A plain SQL statement or one with params in it designated by ?
227
+ :param list params: A list of params in order of precedence
228
+ :param int limit: Number of records to fetch
229
+ :param int skip: Offset of records to skip
230
+ :return: DatabaseResult
231
231
  """
232
232
  # modify the select statement for limit and skip
233
233
  if self.database_engine == self.FIREBIRD:
@@ -250,11 +250,11 @@ class Database:
250
250
 
251
251
  def fetch_one(self, sql, params=[], skip=0):
252
252
  """
253
- Fetch a single record based on a sql statement
254
- :param sql:
255
- :param params:
256
- :param skip:
257
- :return:
253
+ Fetch a single record based on a sql statement, take note that BLOB and byte record data is converted into base64 automatically
254
+ :param str sql: A plain SQL statement or one with params in it designated by ?
255
+ :param list params: A list of params in order of precedence
256
+ :param int skip: Offset of records to skip
257
+ :return: dict : A dictionary containing the single record
258
258
  """
259
259
  # Calling the fetch method with limit as 1 and returning the result
260
260
  sql = self.parse_place_holders(sql)
@@ -287,12 +287,12 @@ class Database:
287
287
  else:
288
288
  return sql.replace("%s", "?")
289
289
 
290
- def execute(self, sql, params=()):
290
+ def execute(self, sql, params=[]):
291
291
  """
292
292
  Execute a query based on a sql statement
293
- :param sql:
294
- :param params:
295
- :return:
293
+ :param str sql: A plain SQL statement or one with params in it designated by ?
294
+ :param list params: A list of params in order of precedence
295
+ :return: DatabaseResult
296
296
  """
297
297
  sql = self.parse_place_holders(sql)
298
298
  cursor = self.dba.cursor()
@@ -313,12 +313,12 @@ class Database:
313
313
  # Return the error in the result
314
314
  return DatabaseResult(None, [], str(e))
315
315
 
316
- def execute_many(self, sql, params=()):
316
+ def execute_many(self, sql, params=[]):
317
317
  """
318
318
  Execute a query based on a single sql statement with a different number of params
319
- :param sql:
320
- :param params:
321
- :return:
319
+ :param sql: A plain SQL statement or one with params in it designated by ?
320
+ :param params: A list of params in order of precedence
321
+ :return: DatabaseResult
322
322
  """
323
323
  sql = self.parse_place_holders(sql)
324
324
  cursor = self.dba.cursor()
@@ -396,9 +396,9 @@ class Database:
396
396
  def insert(self, table_name, data, primary_key="id"):
397
397
  """
398
398
  Insert data based on table name and data provided - single or multiple records
399
- :param primary_key:
400
- :param table_name:
401
- :param data:
399
+ :param str table_name: Name of table
400
+ :param None data: List or Dictionary containing the data to be inserted
401
+ :param str primary_key: The name of the primary key of the table
402
402
  """
403
403
  if isinstance(data, dict):
404
404
  data = [data]
@@ -420,6 +420,7 @@ class Database:
420
420
 
421
421
  records = DatabaseResult()
422
422
 
423
+ result = None
423
424
  for record in data:
424
425
  record = self.sanitize(record)
425
426
  result = self.execute(sql, list(record.values()))
@@ -435,8 +436,8 @@ class Database:
435
436
  def delete(self, table_name, filter=None):
436
437
  """
437
438
  Delete data based on table name and filter provided - single or multiple filters
438
- :param table_name:
439
- :param filter:
439
+ :param str table_name: Name of table
440
+ :param str filter: Expression for deleting records
440
441
  """
441
442
  if self.database_engine in (self.SQLITE, self.FIREBIRD):
442
443
  placeholder = "?"
@@ -452,6 +453,8 @@ class Database:
452
453
 
453
454
  # Updating multiple records - records passed in is a list
454
455
  if isinstance(filter, list):
456
+ sql = ""
457
+ result = None
455
458
  for record in filter:
456
459
  pk_value = []
457
460
  condition_records = []
@@ -476,12 +479,12 @@ class Database:
476
479
  Debug("DELETE ERROR:", sql, result.error, Constant.TINA4_LOG_ERROR)
477
480
  return False
478
481
 
479
- def update(self, table_name, records, primary_key="id"):
482
+ def update(self, table_name, data, primary_key="id"):
480
483
  """
481
484
  Update data based on table name and record/primary key provided - single or multiple records
482
- :param table_name:
483
- :param records:
484
- :param primary_key:
485
+ :param str table_name: Name of table
486
+ :param None data: List or Dictionary containing the data to be inserted
487
+ :param str primary_key: The name of the primary key of the table
485
488
  """
486
489
  if self.database_engine in (self.SQLITE, self.FIREBIRD):
487
490
  placeholder = "?"
@@ -490,14 +493,16 @@ class Database:
490
493
  else:
491
494
  placeholder = "?"
492
495
 
493
- if records is not None:
496
+ if data is not None:
494
497
  # Updating a single record - record passed in is a dictionary
495
- if isinstance(records, dict):
496
- records = [records]
498
+ if isinstance(data, dict):
499
+ data = [data]
497
500
 
498
501
  # Updating multiple records - records passed in is a list
499
- if isinstance(records, list):
500
- for record in records:
502
+ if isinstance(data, list):
503
+ sql = ""
504
+ result = None
505
+ for record in data:
501
506
  pk_value = None
502
507
  condition_records = ""
503
508
  set_clause_list = []
@@ -74,7 +74,7 @@ class Debug:
74
74
  color = ShellColors.bright_yellow
75
75
  log_level = 30
76
76
 
77
- logger.log(log_level, " ".join(str(param) for param in params).strip())
77
+ logger.log(log_level, " ".join(str(param) for param in params[1:]).strip())
78
78
 
79
79
  print(color + f"{debug_level:5}:"+ShellColors.end, "", end="")
80
80
  for output in params:
File without changes