def __init__(self, connection):
     self.connection = connection.connection
     self.create = create.create(self.connection)
     self.create_meta = create.create(self.connection,
                                      include_metadata_timestamps=True)
     self.insert = insert.insert(self.connection,
                                 autoadjust_sql_objects=True)
     self.insert_meta = insert.insert(
         self.connection,
         include_metadata_timestamps=True,
         autoadjust_sql_objects=True,
     )
Exemple #2
0
    def __init__(
        self,
        database: str = "master",
        server: str = "localhost",
        driver: str = None,
        username: str = None,
        password: str = None,
        include_metadata_timestamps: bool = False,
        autoadjust_sql_objects: bool = False,
    ):

        connect.__init__(self, database, server, driver, username, password)

        # log initialization details
        self.log_init()

        # initialize mssql_dataframe functionality with shared connection
        self.exceptions = custom_errors
        self.create = create.create(self.connection, include_metadata_timestamps)
        self.modify = modify.modify(self.connection)
        self.read = read.read(self.connection)
        self.write = write(
            self.connection, include_metadata_timestamps, autoadjust_sql_objects
        )

        # issue warnings for automated functionality
        if include_metadata_timestamps:
            msg = "SQL write operations will include metadata '_time_insert' & '_time_update' columns as 'include_metadata_timestamps=True'."
            logger.warning(msg)

        if autoadjust_sql_objects:
            msg = "SQL objects will be created/modified as needed as 'autoadjust_sql_objects=True'."
            logger.warning(msg)
Exemple #3
0
    def __init__(
        self,
        connection: pyodbc.connect,
        include_metadata_timestamps: bool = False,
        autoadjust_sql_objects: bool = False,
    ):
        """Class for inserting data into SQL.

        Parameters
        ----------
        connection (pyodbc.Connection) : connection for executing statement
        include_metadata_timestamps (bool, default=False) : include metadata timestamps _time_insert & _time_update for write operations
        autoadjust_sql_objects (bool, default=False) : if True, create SQL tables or alter SQL columns if needed
        """
        self._connection = connection
        self.include_metadata_timestamps = include_metadata_timestamps
        self.autoadjust_sql_objects = autoadjust_sql_objects

        # max attempts for creating/modifing SQL tables
        # value of 3 will: add include_metadata_timestamps columns and/or add other columns and/or increase column size
        self._adjust_sql_attempts = 3

        # handle failures if autoadjust_sql_objects==True
        self._modify = modify.modify(connection)
        self._create = create.create(connection)
 def __init__(self, connection):
     self.connection = connection.connection
     self.create = create.create(self.connection)
     self.insert = insert.insert(
         self.connection,
         include_metadata_timestamps=False,
         autoadjust_sql_objects=False,
     )
     self.read = read.read(self.connection)
Exemple #5
0
 def __init__(self, connection):
     self.connection = connection.connection
     self.create = create.create(self.connection)
     self.merge = merge.merge(self.connection, autoadjust_sql_objects=True)
     self.merge_meta = merge.merge(
         self.connection,
         include_metadata_timestamps=True,
         autoadjust_sql_objects=True,
     )
 def __init__(self, connection):
     self.connection = connection.connection
     self.create = create.create(self.connection)
     self.insert = insert.insert(self.connection)
     self.insert_meta = insert.insert(
         self.connection, include_metadata_timestamps=True
     )
     self.insert_errors = insert.insert(self.connection)
     self.insert_errors._adjust_sql_attempts = -1
Exemple #7
0
    def __init__(
        self,
        connection: pyodbc.connect,
        include_metadata_timestamps: bool = False,
        autoadjust_sql_objects: bool = False,
    ):
        self._connection = connection
        self.include_metadata_timestamps = include_metadata_timestamps
        self.autoadjust_sql_objects = autoadjust_sql_objects

        # max attempts for creating/modifing SQL tables
        # value of 3 will: add include_metadata_timestamps columns and/or add other columns and/or increase column size
        self._adjust_sql_attempts = 3

        # handle failures if autoadjust_sql_objects==True
        self._modify = modify.modify(connection)
        self._create = create.create(connection)
Exemple #8
0
 def __init__(self, connection):
     self.connection = connection.connection
     self.create = create.create(self.connection)
     self.update = update.update(self.connection)
     self.update_meta = update.update(self.connection,
                                      include_metadata_timestamps=True)
 def __init__(self, connection):
     self.connection = connection.connection
     self.create = create.create(self.connection)
     self.modify = modify.modify(self.connection)