From a database
Pandas provides capabilities to read and write from many other data sources, including databases. Without installing any additional packages, pandas can interact with SQLite databases; the SQLAlchemy package needs to be installed in order to interact with other database flavors. This interaction can be achieved by opening a connection to the database using the sqlite3 module in the Python standard library and then using either the pd.read_sql() function to query the database or the to_sql() method on a DataFrame object to write to the database.
Before we read from a database, let's write to one. We simply call to_sql() on our dataframe, telling it which table to write to, which database connection to use, and how to handle ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access