rame.to_sql 
    * [ pandas.read_gbq ](pandas.read_gbq.html)
    * [ pandas.read_stata ](pandas.read_stata.html)
    * [ pandas.DataFrame.to_stata ](pandas.DataFrame.to_stata.html)
    * [ pandas.io.stata.StataReader.data_label ](pandas.io.stata.StataReader.data_label.html)
    * [ pandas.io.stata.StataReader.value_labels ](pandas.io.stata.StataReader.value_labels.html)
    * [ pandas.io.stata.StataReader.variable_labels ](pandas.io.stata.StataReader.variable_labels.html)
    * [ pandas.io.stata.StataWriter.write_file ](pandas.io.stata.StataWriter.write_file.html)
  * [ General functions ](../general_functions.html)
  * [ Series ](../series.html)
  * [ DataFrame ](../frame.html)
  * [ pandas arrays, scalars, and data types ](../arrays.html)
  * [ Index objects ](../indexing.html)
  * [ Date offsets ](../offset_frequency.html)
  * [ Window ](../window.html)
  * [ GroupBy ](../groupby.html)
  * [ Resampling ](../resampling.html)
  * [ Style ](../style.html)
  * [ Plotting ](../plotting.html)
  * [ Options and settings ](../options.html)
  * [ Extensions ](../extensions.html)
  * [ Testing ](../testing.html)
  * [ Missing values ](../missing_value.html)

  * [ __ ](../../index.html)
  * [ API reference ](../index.html)
  * [ Input/output ](../io.html)
  * pandas.DataF... 

#  pandas.DataFrame.to_sql  #

DataFrame.  to_sql  (  _ name  _ , _ con  _ , _ *  _ , _ schema  =  None  _ ,
_ if_exists  =  'fail'  _ , _ index  =  True  _ , _ index_label  =  None  _ ,
_ chunksize  =  None  _ , _ dtype  =  None  _ , _ method  =  None  _ )  [
[source]  ](https://github.com/pandas-
dev/pandas/blob/v2.2.2/pandas/core/generic.py#L2873-L3098) #

    

Write records stored in a DataFrame to a SQL database.

Databases supported by SQLAlchemy  [1]  are supported. Tables can be newly
created, appended to, or overwritten.

Parameters  :

    

**name** str

    

Name of SQL table.

**con** sqlalchemy.engine.(Engine or Connection) or sqlite3.Connection

    

Using SQLAlchemy makes it possible to use any DB supported by that library.
Legacy support is provided for sqlite3.Connection objects. The user is
responsible for engine disposal and connection closure for the SQLAlchemy
connectable. See [ here
](https://docs.sqlalchemy.org/en/20/core/connections.html) . If passing a
sqlalchemy.engine.Connection which is already in a transaction, the
transaction will not be committed. If passing a sqlite3.Connection, it will
not be possible to roll back the record insertion.

**schema** str, optional

    

Specify the schema (if database flavor supports this). If None, use default
schema.

**if_exists** {âfailâ, âreplaceâ, âappendâ}, default âfailâ

    

How to behave if the table already exists.

  * fail: Raise a ValueError. 

  * replace: Drop the table before inserting new values. 

  * append: Insert new values to the existing table. 

**index** bool, default True

    

Write DataFrame index as a column. Uses  index_label  as the column name in
the table. Creates a table index for this column.

**index_label** str or sequence, default None

    

Column label for index column(s). If None is given (default) and  index  is
True, then the index names are used. A sequence should be given if the
DataFrame uses MultiIndex.

**chunksize** int, optional

    

Specify the number of rows in each batch to be written at a time. By default,
all rows will be written at once.

**dtype** dict or scalar, optional

    

Specifying the datatype for columns. If a dictionary is used, the keys should
be the column names and the values should be the SQLAlchemy types or strings
for the sqlite3 legacy mode. If a scalar is provided, it will be applied to
all columns.

**method** {None, âmultiâ, callable}, optional

    

Controls the SQL insertion clause used:

  * None : Uses standard SQL ` INSERT  ` clause (one per row). 

  * âmultiâ: Pass multiple values in a single ` INSERT  ` clause. 

  * callable with signature ` (pd_table,  conn,  keys,  data_iter