Skip to content

Commit c57d8db

Browse files
committed
feature/slots
Used slots in classes LightCleaner and DataFrametoSQL to optimize the use of memory
1 parent 4f491a7 commit c57d8db

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

pydbsmgr/fast_upload.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
from pydbsmgr.utils.tools import ColumnsCheck
1313

14-
1514
class DataFrameToSQL(ColumnsCheck):
1615
"""Allows you to create a table from a dataframe"""
1716

17+
__slots__ = ['_connection_string','_con', '_cur' ]
1818
def __init__(self, connection_string: str) -> None:
1919
"""Set the connection with the database"""
2020
self._connection_string = connection_string
@@ -165,6 +165,7 @@ def __init__(self, connection_string: str) -> None:
165165
"""Establish the connection to the database using the `DataFrameToSQL` class."""
166166
super().__init__(connection_string)
167167

168+
168169
def execute(
169170
self,
170171
df: DataFrame,

pydbsmgr/lightest.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import concurrent.futures
22
from functools import partial
3+
from functools import cached_property
34

45
from pydbsmgr.main import *
56
from pydbsmgr.utils.tools import coerce_datetime, most_repeated_item
@@ -42,6 +43,9 @@ def process_dates(x: str, format_type: str, auxiliary_type: str) -> str:
4243
class LightCleaner:
4344
"""Performs a light cleaning on the table"""
4445

46+
#Increase memory efficiency
47+
__slots__ = ['df', 'dict_dtypes']
48+
4549
def __init__(self, df_: DataFrame):
4650
self.df = df_.copy()
4751
self.dict_dtypes = dict(zip(["float", "int", "str"], ["float64", "int64", "object"]))

0 commit comments

Comments
 (0)