将python与mysql集成

A data analyst or data scientist get lots of opportunity to work on Python and SQL. Python with its enormous library support provides data analyst with a magic wand to manipulate and visualize data. Likewise SQL helps us store millions of records and establish relationships with other tables for optimal data management. There are scenarios that require a Python program to directly load data into a back-end database. For example, if a data frame is dynamically modified periodically or at random instances, uploading the csv file for each data update into the database is not feasible. In this post, we will go through how to integrate a Python program with MySQL database.

数据分析师或数据科学家有很多使用Python和SQL的机会。 Python及其强大的库支持为数据分析人员提供了操作和可视化数据的魔杖。 同样,SQL可帮助我们存储数百万条记录并与其他表建立关系,以实现最佳数据管理。 在某些情况下,需要Python程序将数据直接加载到后端数据库中。 例如,如果定期或在随机实例中动态修改数据帧,则将每次数据更新的csv文件上载到数据库中都是不可行的。 在本文中,我们将介绍如何将Python程序与MySQL数据库集成。

First, I created a small dataset in Python. It has two columns, first column stores index and second column stores time stamp.

首先,我用Python创建了一个小的数据集。 它有两列,第一列存储索引,第二列存储时间戳。

from datetime import datetime # Current date time in local system 
col_1 = col_1+1
col_2 = datetime.now()
print('ID:',col_1)
print('Timestamp:',col_2)
Image for post

Creating a table in MySQL

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值