to_sql()

With support from the sqlalchemy package, data can be transferred to databases through pandas: 

from sqlalchemy import create_engine
engine = create_engine('sqlite:///:memory:')
df.to_sql('data_sql',engine)

Data can also be pushed iteratively in batches by using the chunksize argument.

The data type of any column can also be changed when pushing to the database, as shown in the following code:

from sqlalchemy.types import String
df.to_sql('data_dtype', engine, dtype={'Score': String})

The Timedelta datatype, which is not supported across databases, is converted into its equivalent integral value in nanoseconds before being stored in the database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset