modulitiz-micro 2.27.2__py311-none-any.whl → 2.29.0__py311-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.
@@ -23,11 +23,25 @@ class AbstractSql(ABC):
23
23
  with self.lock:
24
24
  self.connDb.rollback()
25
25
 
26
- def initCursore(self):
26
+ def initCursor(self):
27
+ """
28
+ Creates cursor objects, it's needed to read/write database.
29
+ """
27
30
  with self.lock:
28
31
  cursoreDb=self.connDb.cursor()
29
32
  return cursoreDb
30
33
 
34
+ def fetchOne(self,cursoreDb):
35
+ """
36
+ Retrieve first row of query
37
+ """
38
+ with cursoreDb:
39
+ with self.lock:
40
+ result=cursoreDb.fetchone()
41
+ if not result:
42
+ return None
43
+ return result[0]
44
+
31
45
  def count(self,cursoreDb)->int:
32
46
  with cursoreDb:
33
47
  with self.lock:
@@ -18,28 +18,21 @@ class ModuloSqlServer(AbstractSql):
18
18
  self.connDb=connDb
19
19
 
20
20
  def select(self,sql:str,params:list):
21
- with self.initCursore() as cursoreDb:
21
+ with self.initCursor() as cursoreDb:
22
22
  cursoreDb.execute(sql,params)
23
23
  results=list(cursoreDb)
24
24
  return results
25
25
 
26
- @staticmethod
27
- def selectOne(cursoreDb,sql:str,params:list)->list:
28
- """
29
- Scarica la prima riga della query
30
- """
26
+ def select_count(self,cursoreDb,sql:str,params:list)->int:
31
27
  with cursoreDb:
32
28
  cursoreDb.execute(sql,params)
33
- element=cursoreDb.fetchone()
34
- return list(element)
29
+ output=self.count(cursoreDb)
30
+ return output
35
31
 
36
- def select_count(self,cursoreDb,sql:str,params:list)->int:
37
- elemento=self.selectOne(cursoreDb,sql,params)
38
- return int(elemento[0])
39
-
40
- #usare se si vogliono fare delle modifiche ai dati
41
- #tipo: insert, update, delete
42
32
  def modifica(self,cursoreDb,sql:str,params:list,ignore_unique_index:bool):
33
+ """
34
+ Use it for data modifications like: insert, update, delete
35
+ """
43
36
  try:
44
37
  cursoreDb.execute(sql,params)
45
38
  except pypyodbc.IntegrityError as ie:
@@ -79,7 +79,7 @@ WHERE type1=%(paramType)s
79
79
  if addEnabled is True:
80
80
  params['enabled']=enabled
81
81
 
82
- cursoreDb=self.initCursore()
82
+ cursoreDb=self.initCursor()
83
83
  with self.lock:
84
84
  cursoreDb.execute(sql,params)
85
85
  return cursoreDb
@@ -107,7 +107,7 @@ WHERE type1=%(paramType)s
107
107
  params['paramType']=paramType
108
108
  if addParamKey is True:
109
109
  params['paramKey']=paramKey
110
- cursoreDb=self.initCursore()
110
+ cursoreDb=self.initCursor()
111
111
  with self.lock:
112
112
  cursoreDb.execute(sql,params)
113
113
  return cursoreDb
@@ -35,10 +35,16 @@ class AbstractMysql(AbstractSql):
35
35
  # apro la connessione col server
36
36
  self.connDb=mysql.connector.connect(user=user,password=password,host=host,port=porta,
37
37
  converter_class=MysqlCommonConverter)
38
- self.initCursore()
38
+ self.initCursor()
39
39
  self.TABLE_OPTIONS=self.getTableOptions(isDebug)
40
40
  self.isDbNew=None
41
41
 
42
+ @abstractmethod
43
+ def schema(self):
44
+ """
45
+ Insert here sql instructions containing table definitions (DDL)
46
+ """
47
+
42
48
  def initDdl(self):
43
49
  #scelgo il db
44
50
  try:
@@ -46,7 +52,7 @@ class AbstractMysql(AbstractSql):
46
52
  self.isDbNew=False
47
53
  except mysql.connector.ProgrammingError:
48
54
  sqlCreaDb="CREATE DATABASE %s;"%(self.nomeDb,)
49
- with self.initCursore() as cursoreDb:
55
+ with self.initCursor() as cursoreDb:
50
56
  with self.lock:
51
57
  cursoreDb.execute(sqlCreaDb)
52
58
  self.connDb.cmd_init_db(self.nomeDb)
@@ -57,20 +63,26 @@ class AbstractMysql(AbstractSql):
57
63
  for risultati in self.executeScript(sqlStr):
58
64
  yield risultati
59
65
 
60
- @abstractmethod
61
- def schema(self):
66
+ @staticmethod
67
+ def getLastIdInserted(cursoreDb):
68
+ return cursoreDb.lastrowid
69
+
70
+ def selectNow(self):
62
71
  """
63
- Inserire le istruzioni sql contenenti la dichiarazione delle tabelle (DDL)
72
+ Returns current db date and time.
64
73
  """
65
-
66
- def getLastIdInserted(self,cursoreDb):
67
- return cursoreDb.lastrowid
74
+ sql="SELECT {};".format(self.DATE_TIME_NOW)
75
+ with self.initCursor() as cursoreDb:
76
+ with self.lock:
77
+ cursoreDb.execute(sql,{})
78
+ output=self.fetchOne(cursoreDb)
79
+ return output
68
80
 
69
81
  def executeScript(self,sqlStr:str):
70
82
  sqlCmds=sqlStr.split(";")
71
83
  sqlCmds=ModuloListe.eliminaElementiVuoti(sqlCmds)
72
84
  numCmds=len(sqlCmds)
73
- cursoreDb=self.initCursore()
85
+ cursoreDb=self.initCursor()
74
86
  for index,sqlCmd in enumerate(sqlCmds):
75
87
  sqlCmd=sqlCmd.strip()
76
88
  try:
@@ -11,7 +11,7 @@ class AbstractBasicSqlite(AbstractSqlite):
11
11
  if not self.isDbNew:
12
12
  return
13
13
  sql_str=ModuloStringhe.normalizzaEol(self.schemaBasicTables())
14
- with self.initCursore() as cursoreDb:
14
+ with self.initCursor() as cursoreDb:
15
15
  with self.lock:
16
16
  cursoreDb.executescript(sql_str)
17
17
  sql_insertBasicTables=self.insertBasicTables()
@@ -79,7 +79,7 @@ WHERE type=:paramType
79
79
  params['langCode']=langCode
80
80
  if addEnabled is True:
81
81
  params['enabled']=enabled
82
- cursoreDb=self.initCursore()
82
+ cursoreDb=self.initCursor()
83
83
  with self.lock:
84
84
  cursoreDb.execute(sql,params)
85
85
  return cursoreDb
@@ -107,7 +107,7 @@ WHERE type=:paramType
107
107
  params['paramType']=paramType
108
108
  if addParamKey is True:
109
109
  params['paramKey']=paramKey
110
- cursoreDb=self.initCursore()
110
+ cursoreDb=self.initCursor()
111
111
  with self.lock:
112
112
  cursoreDb.execute(sql,params)
113
113
  return cursoreDb
@@ -35,6 +35,11 @@ class AbstractSqlite(AbstractSql):
35
35
 
36
36
  TIMEOUT_CONNECTION=10
37
37
 
38
+ @abstractmethod
39
+ def schema(self):
40
+ """
41
+ Insert here sql instructions containing table definitions (DDL)
42
+ """
38
43
 
39
44
  def __init__(self,nomefile_db:str,show_sql:bool=False):
40
45
  super().__init__()
@@ -45,7 +50,7 @@ class AbstractSqlite(AbstractSql):
45
50
  connDb.row_factory=sqlite3.Row
46
51
  self.connDb=connDb
47
52
  # creo il cursore, deve essere fatto dopo il row factory
48
- with self.initCursore() as cursoreDb:
53
+ with self.initCursor() as cursoreDb:
49
54
  # setup iniziale
50
55
  with self.lock:
51
56
  # non puoi cancellare un record se e' referenziato da un'altra tabella
@@ -61,13 +66,8 @@ class AbstractSqlite(AbstractSql):
61
66
  cursoreDb.executescript(sql_str)
62
67
  self.commit()
63
68
 
64
- @abstractmethod
65
- def schema(self):
66
- """
67
- Inserire le istruzioni sql contenenti la dichiarazione delle tabelle (DDL)
68
- """
69
-
70
- def getLastIdInserted(self,cursoreDb):
69
+ @staticmethod
70
+ def getLastIdInserted(cursoreDb):
71
71
  return cursoreDb.lastrowid
72
72
 
73
73
  def paginazione(first_result:int,num_results:int)->str:
@@ -58,7 +58,7 @@ WHERE type=:tipo
58
58
  if add_chiave is True:
59
59
  params['chiave']=chiave
60
60
 
61
- cursoreDb=self.initCursore()
61
+ cursoreDb=self.initCursor()
62
62
  cursoreDb.execute(sql,params)
63
63
  return cursoreDb
64
64
 
@@ -70,7 +70,7 @@ type,key,valore,data_insert
70
70
  :tipo,:chiave,:valore,"""+self.DATE_TIME_NOW+"""
71
71
  );
72
72
  """
73
- cursoreDb=self.initCursore()
73
+ cursoreDb=self.initCursor()
74
74
  cursoreDb.execute(sql,{
75
75
  'tipo':tipo,'chiave':chiave,'valore':valore
76
76
  })
@@ -83,7 +83,7 @@ SET valore=:valore,data_insert="""+self.DATE_TIME_NOW+"""
83
83
  WHERE type=:tipo AND key=:chiave
84
84
  ;
85
85
  """
86
- cursoreDb=self.initCursore()
86
+ cursoreDb=self.initCursor()
87
87
  cursoreDb.execute(sql,{
88
88
  'valore':valore,'tipo':tipo,'chiave':chiave
89
89
  })
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: modulitiz_micro
3
- Version: 2.27.2
3
+ Version: 2.29.0
4
4
  Summary: Raccolta dei miei moduli - versione micro
5
5
  Author-email: tiz <sderfo1234@altervista.org>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -16,16 +16,16 @@ modulitiz_micro/android/ModuloAndroidSim.py,sha256=UWfpMJSw6xktKdUzr0Snsy47ZHpHh
16
16
  modulitiz_micro/android/beans/SmsBean.py,sha256=_7dZbNrHi5CFt3Z0SrqFV3VVb2QuKVfwBnsvC6cGDQc,444
17
17
  modulitiz_micro/android/enums/AndroidSmsTypeEnum.py,sha256=3jE5ZhtlXPZNYbs0U07igQeRBN8uZyxHXxW3C4hXZ0I,265
18
18
  modulitiz_micro/database/AbstractDatabaseService.py,sha256=iVi43Hhvo7L-BUSWowm-AUcW4Ecnbvyk_0ZFgZZMQwE,270
19
- modulitiz_micro/database/AbstractSql.py,sha256=QOIQKij1jK5b8txyLvhinFkra9Rf-4i42V04RfKhDKg,994
19
+ modulitiz_micro/database/AbstractSql.py,sha256=5WlopcCKRfxrvIQAs5Sygtf_QNJShWfL4KGAnbx2lF4,1276
20
20
  modulitiz_micro/database/ModuloSqlOracle.py,sha256=82pDbbT5sqe4rMcUzu9Nb2e7bROgs53yg1ufCg8GGkw,484
21
- modulitiz_micro/database/ModuloSqlServer.py,sha256=EqMVgjeR78513PSlNJBL34x7yg_cT-mdUtAyRIH60nQ,1452
21
+ modulitiz_micro/database/ModuloSqlServer.py,sha256=jPIavBeX5VRue0yfqtvwvNiu40q8YgWIcqeo_PsJSQM,1235
22
22
  modulitiz_micro/database/eccezioni/EccezioneDbNoData.py,sha256=eXcD3x3-3Wf6SFMEyQZj24KccHhVnSZteM9pkrsGU-g,186
23
- modulitiz_micro/database/mysql/AbstractBasicMysql.py,sha256=C03qCWI3-8sCrp_CFfgPmSPal6USiH5EteFa0Q3i3Rs,3581
24
- modulitiz_micro/database/mysql/ModuloMysql.py,sha256=rxkDxenARlSWGt-3FcOIqLl6OUPQpOvUiBlal1L1o70,5275
23
+ modulitiz_micro/database/mysql/AbstractBasicMysql.py,sha256=X3wjpemOc9QsHZ77xqheesCCc31ocOf0ori9BOQpR74,3579
24
+ modulitiz_micro/database/mysql/ModuloMysql.py,sha256=WflNHypWWa9bl-os8d7WwDCV91ktVktx3iP594RLRUA,5540
25
25
  modulitiz_micro/database/mysql/MysqlCommonConverter.py,sha256=jZFQykrgZ3L-hALfnCXnnN54OVfqb8xFtZs48WRt8nc,1336
26
26
  modulitiz_micro/database/mysql/eccezioni/EccezioneMysqlOffline.py,sha256=gKNgFegRSYCNrNBlaq2helOyMhXjpVC_DKCt-i341Gs,164
27
- modulitiz_micro/database/sqlite/AbstractBasicSQLite.py,sha256=QspbJoa1btiHjuETSPOh4QJ550T6_dPRildBa0KNIMU,3470
28
- modulitiz_micro/database/sqlite/ModuloSQLite.py,sha256=Pw6Y4I-ktLUoFqrJPgW98A5y4LM6-cT6xC3O9t6K7Jk,2389
27
+ modulitiz_micro/database/sqlite/AbstractBasicSQLite.py,sha256=fGTHx9fc86cvXo7xsatAP00C1IfKv6Kv9MoQa1nEUJw,3467
28
+ modulitiz_micro/database/sqlite/ModuloSQLite.py,sha256=uw60sLvFcJ82ems2tyQ9hzFAdHxGaf0JoQ-gO-QvsvI,2385
29
29
  modulitiz_micro/eccezioni/EccezioneBase.py,sha256=sRzCwhMDC4sDSchT7j1y-bLxKyqDTD9pc6Df7qggZ9Q,193
30
30
  modulitiz_micro/eccezioni/EccezioneCtrlC.py,sha256=-O5oG2ZkX7NoWLDewLETX5a20Ea4AYashf8TFwsuatc,185
31
31
  modulitiz_micro/eccezioni/EccezioneRuntime.py,sha256=lSwwGf_AsW6EjwkB88oF_mpLKQHj0fdjOy8H3uWRRBo,168
@@ -39,7 +39,7 @@ modulitiz_micro/files/ModuloLogging.py,sha256=2MFqARcV7HvQDT4RwCuAh_Rju9lyXu6vaG
39
39
  modulitiz_micro/files/ModuloZip.py,sha256=eBI54TPFyOm6PjPoNU6fnrdHxCHK8iYxeYK2RwonLGs,1359
40
40
  modulitiz_micro/files/cache/CacheBean.py,sha256=EpOPXfg30oLLJ41wD-jTu9RhNCTRtGSlQcXPcBIj-Yg,133
41
41
  modulitiz_micro/files/cache/CacheRam.py,sha256=iozy7AXCs-Tkn1HS_w7wovdzkCtRbyDbb2n9wVe3FPs,990
42
- modulitiz_micro/files/cache/DatabaseCache.py,sha256=FXA4ktqTiHlZynE8dZ16aZwNtxPZYd8MmyqmkvF9C_s,2394
42
+ modulitiz_micro/files/cache/DatabaseCache.py,sha256=MD0eWEgQhOAmGTbm893rhcc9Nxf_vbr7z2bhqkyQJEk,2391
43
43
  modulitiz_micro/files/cache/decorators/cacheRam.py,sha256=FQRzcNWTZKpU9cyrpWIumgg9GKGNBznTmSfok1QgvZM,770
44
44
  modulitiz_micro/files/git/ModuloGit.py,sha256=ndgjU4smxINWMEujSQTjxqqfeVWBvueQRkMKKST9siw,383
45
45
  modulitiz_micro/gestionedom/GestioneDom.py,sha256=LjmFKiBLNc0yn9m7Z27u2rpU4UcF9778Ljm8aYhdBcY,1350
@@ -94,8 +94,8 @@ modulitiz_micro/util/unittesting/ModuloRunUnitTest.py,sha256=_YHxjTk_t9wvlCYgS4H
94
94
  modulitiz_micro/util/wheel/ModuloBuildWheel.py,sha256=-NTUqEjmGl8OUFa1hSwmBbLOaoJZhmzStvOexIN6CDo,5039
95
95
  modulitiz_micro/util/wheel/ModuloToml.py,sha256=774GQ8y6lyhOrT0edJPlLq4TBU7Nq4699q74deGlFW4,1205
96
96
  modulitiz_micro/util/wheel/ModuloWheel.py,sha256=VRS_6kSt62qubBYzkGm91_GWzcIiD0KlSnaqhM_aQnE,338
97
- modulitiz_micro-2.27.2.dist-info/LICENSE,sha256=b-Ia9Hv3N_FviXoFAXG44lDGbk4tCC0fBdduccm8nl0,1086
98
- modulitiz_micro-2.27.2.dist-info/METADATA,sha256=Gbl9RlQGcEi_e3HKZEc8J223IW9UbcS-KoiAORs6cLk,1651
99
- modulitiz_micro-2.27.2.dist-info/WHEEL,sha256=2aRSX09k7pmd4gPs96VOQ860h0v0t30ka6JGHtpC3BY,94
100
- modulitiz_micro-2.27.2.dist-info/top_level.txt,sha256=ESJE0qtNJp3tbKPrffbFVjH511NSjJHxscfpdLjTpA8,16
101
- modulitiz_micro-2.27.2.dist-info/RECORD,,
97
+ modulitiz_micro-2.29.0.dist-info/LICENSE,sha256=b-Ia9Hv3N_FviXoFAXG44lDGbk4tCC0fBdduccm8nl0,1086
98
+ modulitiz_micro-2.29.0.dist-info/METADATA,sha256=uDzDXN_BZH9Ej-LAiQHbAl9tASB_ITlaV9Lf5oZhpKk,1651
99
+ modulitiz_micro-2.29.0.dist-info/WHEEL,sha256=2aRSX09k7pmd4gPs96VOQ860h0v0t30ka6JGHtpC3BY,94
100
+ modulitiz_micro-2.29.0.dist-info/top_level.txt,sha256=ESJE0qtNJp3tbKPrffbFVjH511NSjJHxscfpdLjTpA8,16
101
+ modulitiz_micro-2.29.0.dist-info/RECORD,,