src/sql/magic.py
def _persist_dataframe(self, raw, conn, user_ns, append=False):
        """Implements PERSIST, which writes a DataFrame to the RDBMS"""
        if not DataFrame:
            raise ImportError("Must `pip install pandas` to use DataFrames")

        frame_name = raw.strip(";")

        # Get the DataFrame from the user namespace
        if not frame_name:
            raise SyntaxError("Syntax: %sql --persist <name_of_data_frame>")
        try:
            frame = eval(frame_name, user_ns)
        except SyntaxError:
            raise SyntaxError("Syntax: %sql --persist <name_of_data_frame>")
        if not isinstance(frame, DataFrame) and not isinstance(frame, Series):
            raise TypeError("%s is not a Pandas DataFrame or Series" % frame_name)

        # Make a suitable name for the resulting database table
        table_name = frame_name.lower()
        table_name = self.legal_sql_identifier.search(table_name).group(0)

        if_exists = "append" if append else "fail"
        frame.to_sql(table_name, conn.session.engine, if_exists=if_exists)
        return "Persisted %s" % table_name
Implements PERSIST, which writes a DataFrame to the RDBMS
Implements PERSIST, which writes a DataFrame to the RDBMS
Implements PERSIST which writes a DataFrame to the RDBMS
def _persist_dataframe(self, raw, conn, user_ns, append=False):
        if not DataFrame:
            raise ImportError("Must `pip install pandas` to use DataFrames")
        frame_name = raw.strip(";")
        if not frame_name:
            raise SyntaxError("Syntax: %sql --persist <name_of_data_frame>")
        try:
            frame = eval(frame_name, user_ns)
        except SyntaxError:
            raise SyntaxError("Syntax: %sql --persist <name_of_data_frame>")
        if not isinstance(frame, DataFrame) and not isinstance(frame, Series):
            raise TypeError("%s is not a Pandas DataFrame or Series" % frame_name)
        table_name = frame_name.lower()
        table_name = self.legal_sql_identifier.search(table_name).group(0)
        if_exists = "append" if append else "fail"
        frame.to_sql(table_name, conn.session.engine, if_exists=if_exists)
        return "Persisted %s" % table_name
def _persist_dataframe ( self , raw , conn , user_ns , append = False ) : if not DataFrame : raise ImportError ( "Must `pip install pandas` to use DataFrames" ) frame_name = raw . strip ( ";" ) if not frame_name : raise SyntaxError ( "Syntax: %sql --persist <name_of_data_frame>" ) try : frame = eval ( frame_name , user_ns ) except SyntaxError : raise SyntaxError ( "Syntax: %sql --persist <name_of_data_frame>" ) if not isinstance ( frame , DataFrame ) and not isinstance ( frame , Series ) : raise TypeError ( "%s is not a Pandas DataFrame or Series" % frame_name ) table_name = frame_name . lower ( ) table_name = self . legal_sql_identifier . search ( table_name ) . group ( 0 ) if_exists = "append" if append else "fail" frame . to_sql ( table_name , conn . session . engine , if_exists = if_exists ) return "Persisted %s" % table_name
Implements PERSIST, which writes a DataFrame to the RDBMS
Implements PERSIST which writes a DataFrame to the RDBMS
"""Implements PERSIST, which writes a DataFrame to the RDBMS""" # Get the DataFrame from the user namespace # Make a suitable name for the resulting database table
self
raw
conn
user_ns
append