to_sql(conn, table_name, dbapi_module=None, use_python_type_specifiers=False, use_exact_column_names=True)¶
Convert an SFrame to a single table in a SQL database.
This function does not attempt to create the table or check if a table named table_name exists in the database. It simply assumes that table_name exists in the database and appends to it.
to_sql can be thought of as a convenience wrapper around parameterized SQL insert statements.
- conn : dbapi2.Connection
A DBAPI2 connection object. Any connection object originating from the ‘connect’ method of a DBAPI2-compliant package can be used.
- table_name : str
The name of the table to append the data in this SFrame.
- dbapi_module : module | package, optional
The top-level DBAPI2 module/package that constructed the given connection object. By default, a best guess of which module the connection came from is made. In the event that this guess is wrong, this will need to be specified.
- use_python_type_specifiers : bool, optional
If the DBAPI2 module’s parameter marker style is ‘format’ or ‘pyformat’, attempt to use accurate type specifiers for each value (‘s’ for string, ‘d’ for integer, etc.). Many DBAPI2 modules simply use ‘s’ for all types if they use these parameter markers, so this is False by default.
- use_exact_column_names : bool, optional
Specify the column names of the SFrame when inserting its contents into the DB. If the specified table does not have the exact same column names as the SFrame, inserting the data will fail. If False, the columns in the SFrame are inserted in order without care of the schema of the DB table. True by default.