Pharmaceutical company researchers summarized database operations using Python

Introduction

Here, we will explain how to operate MySQL with Python.

Create a new record

To register the table saved by csv in MySQL, do as follows.

import pandas as pd
import sqlalchemy as sa


url =Database connection information
engine = sa.create_engine(url)

df = pd.read_csv(file name)
df.to_sql(table name, engine, index=False, if_exists='replace')

By changing ʻif_exists of the pandas.to_sql method to ʻappend, it will be added instead of overwritten.

Summary

Here, I explained how to add data to MySQL using Python. With SQL Alchemy, you can register data in the database without writing SQL directly.

Reference materials / links

What is the programming language Python? Can it be used for AI and machine learning?

Recommended Posts

Pharmaceutical company researchers summarized database operations using Python
Pharmaceutical company researchers summarized web scraping using Python
Pharmaceutical company researchers summarized Python control statements
Pharmaceutical company researchers summarized Python unit tests
Pharmaceutical company researchers summarized classes in Python
Pharmaceutical company researchers summarized functions in Python
Pharmaceutical company researchers summarized Python exception handling
Pharmaceutical company researchers summarized Python coding standards
Pharmaceutical company researchers summarized variables in Python
Pharmaceutical company researchers summarized regular expressions in Python
Pharmaceutical company researchers summarized file scanning in Python
Pharmaceutical company researchers summarized SciPy
Pharmaceutical company researchers summarized RDKit
Pharmaceutical company researchers summarized scikit-learn
Pharmaceutical company researchers summarized Pandas
Pharmaceutical company researchers summarized NumPy
Pharmaceutical company researchers summarized Matplotlib
Pharmaceutical company researchers summarized Seaborn
Pharmaceutical company researchers have summarized the operators used in Python
Pharmaceutical company researchers summarized Python's data structures
How to install Python for pharmaceutical company researchers
A pharmaceutical company researcher summarized the basic description rules of Python
Summary of Excel operations using OpenPyXL in Python
Scraping using Python
VBA users tried using Python / R: basic arithmetic operations
Create a company name extractor with python using JCLdic