sangreal_db/core/database.py
def insert(self, table, insert_obj, ignore=True):
        """[insert bulk data]

        Arguments:
            table {[DeclarativeMeta cls]} -- [reflection of table]
            insert_obj {[pd.DataFrame or list of dicts]} -- [insert_obj]

        Keyword Arguments:
            ignore {bool} -- [wether ignore exception or not] (default: {True})

        Raises:
            ValueError -- [f"The {reprlib.repr(insert_obj)} must be list of dicts type!"]

        Returns:
            [type] -- [description]
        """

        if isinstance(insert_obj, pd.DataFrame):
            if insert_obj.empty:
                raise ValueError('The input DataFrame is empty, please check!')
            insert_obj = insert_obj.to_dict(orient='records')
        elif not isinstance(insert_obj, list):
            raise ValueError(
                f"The {reprlib.repr(insert_obj)} must be list of dicts type!")

        ignore_str = 'IGNORE' if ignore else ''
        return self._session.execute(
            table.__table__.insert().prefix_with(ignore_str), insert_obj)
def insert(self, table, insert_obj, ignore=True):
        """[insert bulk data]

        Arguments:
            table {[DeclarativeMeta cls]} -- [reflection of table]
            insert_obj {[pd.DataFrame or list of dicts]} -- [insert_obj]

        Keyword Arguments:
            ignore {bool} -- [wether ignore exception or not] (default: {True})

        Raises:
            ValueError -- [f"The {reprlib.repr(insert_obj)} must be list of dicts type!"]

        Returns:
            [type] -- [description]
        """

        if isinstance(insert_obj, pd.DataFrame):
            if insert_obj.empty:
                raise ValueError('The input DataFrame is empty, please check!')
            insert_obj = insert_obj.to_dict(orient='records')
        elif not isinstance(insert_obj, list):
            raise ValueError(
                f"The {reprlib.repr(insert_obj)} must be list of dicts type!")

        ignore_str = 'IGNORE' if ignore else ''
        return self._session.execute(
            table.__table__.insert().prefix_with(ignore_str), insert_obj)
def insert ( self , table , insert_obj , ignore = True ) : if isinstance ( insert_obj , pd . DataFrame ) : if insert_obj . empty : raise ValueError ( 'The input DataFrame is empty, please check!' ) insert_obj = insert_obj . to_dict ( orient = 'records' ) elif not isinstance ( insert_obj , list ) : raise ValueError ( f"The {reprlib.repr(insert_obj)} must be list of dicts type!" ) ignore_str = 'IGNORE' if ignore else '' return self . _session . execute ( table . __table__ . insert ( ) . prefix_with ( ignore_str ) , insert_obj )
[insert bulk data]

        Arguments:
            table {[DeclarativeMeta cls]} -- [reflection of table]
            insert_obj {[pd.DataFrame or list of dicts]} -- [insert_obj]

        Keyword Arguments:
            ignore {bool} -- [wether ignore exception or not] (default: {True})

        Raises:
            ValueError -- [f"The {reprlib.repr(insert_obj)} must be list of dicts type!"]

        Returns:
            [type] -- [description]
[ insert bulk data ]