berryworld 1.0.0.197234__py3-none-any.whl → 1.0.0.197723__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.
- berryworld/sql_connenction.py +5 -27
- {berryworld-1.0.0.197234.dist-info → berryworld-1.0.0.197723.dist-info}/METADATA +1 -1
- {berryworld-1.0.0.197234.dist-info → berryworld-1.0.0.197723.dist-info}/RECORD +6 -6
- {berryworld-1.0.0.197234.dist-info → berryworld-1.0.0.197723.dist-info}/WHEEL +0 -0
- {berryworld-1.0.0.197234.dist-info → berryworld-1.0.0.197723.dist-info}/licenses/LICENSE +0 -0
- {berryworld-1.0.0.197234.dist-info → berryworld-1.0.0.197723.dist-info}/top_level.txt +0 -0
berryworld/sql_connenction.py
CHANGED
|
@@ -2,7 +2,6 @@ import os
|
|
|
2
2
|
import re
|
|
3
3
|
import ast
|
|
4
4
|
import math
|
|
5
|
-
import time
|
|
6
5
|
import pyodbc
|
|
7
6
|
import traceback
|
|
8
7
|
import numpy as np
|
|
@@ -10,7 +9,6 @@ import pandas as pd
|
|
|
10
9
|
import sqlalchemy as sa
|
|
11
10
|
from urllib import parse
|
|
12
11
|
from numbers import Number
|
|
13
|
-
from threading import Thread
|
|
14
12
|
from sqlalchemy.pool import QueuePool
|
|
15
13
|
|
|
16
14
|
|
|
@@ -1029,7 +1027,7 @@ class SQLPoolEngine:
|
|
|
1029
1027
|
""" Connect a Pool Engine to a Microsoft SQL """
|
|
1030
1028
|
|
|
1031
1029
|
def __init__(self, db_reference, server, master=False, trusted_certificate=True, encrypt=True, multi_db=False,
|
|
1032
|
-
commit_as_transaction=True, pool_size=10, max_overflow=10, pool_timeout=30
|
|
1030
|
+
commit_as_transaction=True, pool_size=10, max_overflow=10, pool_timeout=30):
|
|
1033
1031
|
""" Initialize the class
|
|
1034
1032
|
It requires the
|
|
1035
1033
|
SQL-DBREFERENCE-PROD = 'server_name db_name user password'
|
|
@@ -1049,7 +1047,6 @@ class SQLPoolEngine:
|
|
|
1049
1047
|
:param pool_size: Number of connections to keep in the pool
|
|
1050
1048
|
:param max_overflow: Extra connections beyond pool_size
|
|
1051
1049
|
:param pool_timeout: Timeout for getting a connection
|
|
1052
|
-
:param timeout: Connection timeout in seconds
|
|
1053
1050
|
"""
|
|
1054
1051
|
self.con_string_read = None
|
|
1055
1052
|
self.con_string_write = None
|
|
@@ -1060,7 +1057,6 @@ class SQLPoolEngine:
|
|
|
1060
1057
|
self.pool_size = pool_size
|
|
1061
1058
|
self.max_overflow = max_overflow
|
|
1062
1059
|
self.pool_timeout = pool_timeout
|
|
1063
|
-
self.timeout = timeout
|
|
1064
1060
|
|
|
1065
1061
|
self.db_reference = db_reference.replace("_", "") if "_" in db_reference else db_reference
|
|
1066
1062
|
self.server = server
|
|
@@ -1103,9 +1099,6 @@ class SQLPoolEngine:
|
|
|
1103
1099
|
|
|
1104
1100
|
self.create_write_engine(commit_as_transaction=self.commit_as_transaction)
|
|
1105
1101
|
|
|
1106
|
-
# Dispose the engine after a certain timeout
|
|
1107
|
-
Thread(target=self.dispose_engine, args=(self.timeout,)).start()
|
|
1108
|
-
|
|
1109
1102
|
def credentials(self):
|
|
1110
1103
|
""" Return the credentials used to connect to the SQL Server
|
|
1111
1104
|
:return: Dictionary with the credentials used to connect to the SQL Server
|
|
@@ -1160,8 +1153,7 @@ class SQLPoolEngine:
|
|
|
1160
1153
|
poolclass=QueuePool,
|
|
1161
1154
|
pool_size=self.pool_size, # Number of connections to keep in the pool
|
|
1162
1155
|
max_overflow=self.max_overflow, # Extra connections beyond pool_size
|
|
1163
|
-
pool_timeout=self.pool_timeout
|
|
1164
|
-
pool_recycle=self.timeout # Recycle connections after X minutes
|
|
1156
|
+
pool_timeout=self.pool_timeout # Timeout for getting a connection
|
|
1165
1157
|
)
|
|
1166
1158
|
|
|
1167
1159
|
if not commit_as_transaction:
|
|
@@ -1182,8 +1174,7 @@ class SQLPoolEngine:
|
|
|
1182
1174
|
poolclass=QueuePool,
|
|
1183
1175
|
pool_size=10, # Number of connections to keep in the pool
|
|
1184
1176
|
max_overflow=10, # Extra connections beyond pool_size
|
|
1185
|
-
pool_timeout=30
|
|
1186
|
-
pool_recycle=self.timeout # Recycle connections after X minutes
|
|
1177
|
+
pool_timeout=30 # Timeout for getting a connection
|
|
1187
1178
|
)
|
|
1188
1179
|
|
|
1189
1180
|
if not commit_as_transaction:
|
|
@@ -1197,13 +1188,10 @@ class SQLPoolEngine:
|
|
|
1197
1188
|
self.create_read_engine(commit_as_transaction=commit_as_transaction)
|
|
1198
1189
|
self.con = self.engine_read.connect().connection
|
|
1199
1190
|
|
|
1200
|
-
def dispose_engine(self
|
|
1191
|
+
def dispose_engine(self):
|
|
1201
1192
|
""" Dispose any opened engines with the Server
|
|
1202
1193
|
:return: None
|
|
1203
1194
|
"""
|
|
1204
|
-
if timeout > 0:
|
|
1205
|
-
time.sleep(timeout)
|
|
1206
|
-
|
|
1207
1195
|
if self.engine_read:
|
|
1208
1196
|
self.engine_read.dispose()
|
|
1209
1197
|
|
|
@@ -1255,26 +1243,16 @@ class SQLConnectionPool:
|
|
|
1255
1243
|
self.commit_as_transaction = pool_class.commit_as_transaction
|
|
1256
1244
|
self.db_name = pool_class.db_name
|
|
1257
1245
|
self.server = pool_class.server
|
|
1258
|
-
self.timeout = pool_class.timeout
|
|
1259
|
-
|
|
1260
|
-
Thread(target=self.close_connection, args=(self.timeout,)).start()
|
|
1261
1246
|
|
|
1262
|
-
def close_connection(self
|
|
1247
|
+
def close_connection(self):
|
|
1263
1248
|
""" Close any opened connections with the Server
|
|
1264
1249
|
:return: None
|
|
1265
1250
|
"""
|
|
1266
|
-
if timeout > 0:
|
|
1267
|
-
time.sleep(timeout)
|
|
1268
|
-
|
|
1269
1251
|
if self.con_read is not None:
|
|
1270
1252
|
self.con_read.close()
|
|
1271
|
-
if self.engine_read:
|
|
1272
|
-
self.engine_read.dispose()
|
|
1273
1253
|
|
|
1274
1254
|
if self.con_write is not None:
|
|
1275
1255
|
self.con_write.close()
|
|
1276
|
-
if self.engine_write:
|
|
1277
|
-
self.engine_write.dispose()
|
|
1278
1256
|
|
|
1279
1257
|
def query(self, sql_query, coerce_float=False):
|
|
1280
1258
|
""" Read data from SQL according to the sql_query
|
|
@@ -19,19 +19,19 @@ berryworld/power_automate.py,sha256=V86QEGG9H36DrDvod9Q6yp8OUu307hfYcXJhw06pYrA,
|
|
|
19
19
|
berryworld/sharepoint_con.py,sha256=nmyZJIcaAKJ6Y-ti4gQbvzA_rRbrMGIxTDXe4eP-tiI,44950
|
|
20
20
|
berryworld/snowflake_conn.py,sha256=L0ePgTKa3tvaxj88BZmsjS6cFp3ZU3rytw7S2jkuA-U,3161
|
|
21
21
|
berryworld/sql_conn.py,sha256=6kUR3oLXweakz2IBc4zI1ZMqRoN8K6nbQneHhenM-7I,47668
|
|
22
|
-
berryworld/sql_connenction.py,sha256=
|
|
22
|
+
berryworld/sql_connenction.py,sha256=IJAOsQ7p0tMFEEucazmmkS3lNonf_YFWftyZ_kGPHj8,104150
|
|
23
23
|
berryworld/teams_logging.py,sha256=8NwXyWr4fLj7W6GzAm2nRQCGFDxibQpAHDHHD24FrP8,6997
|
|
24
24
|
berryworld/transportation_solver.py,sha256=tNc1JJk71azIBccdWVHbqcvXWhalOdKffv6HmBD6tG0,5014
|
|
25
25
|
berryworld/verify_keys.py,sha256=X7VUHqYDklWPDO0bGVHIOXeLq5Qi4fZRZbHYw5x7UnA,4356
|
|
26
26
|
berryworld/vivantio.py,sha256=QfZo0UKqkzVRg_LyiwivNd3aEup4TH57x4KxLZkCJwc,10627
|
|
27
27
|
berryworld/vivantio_logging.py,sha256=ciy7gA4u3FrgUIpEBnMgocbNPp6jcu9TPoy-kLcrTZU,5736
|
|
28
28
|
berryworld/xml_parser.py,sha256=HWD71NaTN3DaIOGT6Wzxs4CEsroFhGQwe9iPLIL80Co,957
|
|
29
|
-
berryworld-1.0.0.
|
|
29
|
+
berryworld-1.0.0.197723.dist-info/licenses/LICENSE,sha256=vtkVCJM6E2af2gnsi2XxKPr4WY-uIbvzVLXieFND0UU,1074
|
|
30
30
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
tests/test_allocation_config.py,sha256=e12l6fE9U57eSPS35g6ekJ_hol7-RHg89JV60_m1BlE,4633
|
|
32
32
|
tests/test_handy_mix_config.py,sha256=Un56mz9KJmdn4K4OwzHAHLSRzDU1Xv2nFrONNuzOG04,2594
|
|
33
33
|
tests/test_xml_parser.py,sha256=3QTlhFEd6KbK6nRFKZnc35tad6wqukTbe4QrFi8mr_8,859
|
|
34
|
-
berryworld-1.0.0.
|
|
35
|
-
berryworld-1.0.0.
|
|
36
|
-
berryworld-1.0.0.
|
|
37
|
-
berryworld-1.0.0.
|
|
34
|
+
berryworld-1.0.0.197723.dist-info/METADATA,sha256=Btf-waInlfkM3ovW6JgnQaM2Nytj0gy0xbMDY_ppEG8,1445
|
|
35
|
+
berryworld-1.0.0.197723.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
36
|
+
berryworld-1.0.0.197723.dist-info/top_level.txt,sha256=GIZ5qy-P5oxfEH755vA1IMFeTVdX3-40JxMe6nOe5I8,17
|
|
37
|
+
berryworld-1.0.0.197723.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|