![]() ![]() Then it is exported to a table in the PostgreSQL table and it can be verified by browsing the database using PGAdmin – a web-based GUI tool to manage PostgreSQL database servers.Īs you can see in the figure above, the data is now available in the PostgreSQL database. Once you execute the above script, the data will be read from the CSV file mention in the program and stored in a data frame. ![]() In this article, we will also leverage this library as we are working with pandas and it requires the sqlalchemy library to interact with the databases.įigure 3 – Importing and exporting data from pandas dataframe To learn more about Sqlalchemy and not it works, you can read the official documentation from here. Sqlalchemy supports a wide range of databases like SQLServer, Oracle, MySQL, PostgreSQL etc. Using this library, you can implement a lot of database-related activities just by writing a few lines of code. ![]() Sqlalchemy has been around for quite a long time now and is considered one of the most reliable enterprise-wide ORM for pythonic applications. When we talk about exporting data from python, especially pandas, it heavily relies on another library called sqlalchemy. I am assuming that you have already started exploring databases and now created a data frame within your application. In one of my previous articles Exploring databases in Python using Pandas, I have explained about reading data from database and files using pandas and this article can be considered as a continuation of the previous one. This data can then be read by other services in downstream. While working on any application, it is often a requirement that you would need to export your data from the python application to a data store such as a database or a flat-file. Once you have installed the library, you can check the version that has been installed by running the command below.įigure 2 – Checking the version of the library Exporting data from Python using Pandas The only dependency is that you must have a version of python running on your machine prior to installing the library. It is covered under the BSD license, so you can use it for free. You can install it on your machine by running the command below. Personally, I love using the library due to the ease of use and the great documentation that is available online. Pandas is one of the most popular libraries used for the purpose of data analysis. In my previous article Getting started with Pandas in Python, I have explained in detail how to get started with analyzing data in python. In this article, I am going to discuss the various ways in which we can use Pandas in python to export data to a database table or a file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |