반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- AWS CI/CD 구축하기
- COALESCE
- IntelliJ
- codedeploy error
- aws
- Python
- docker
- codedeploy
- PostgreSQL
- kubeflow
- codebuild
- Spring Error
- VPN
- chartjs
- codepipeline
- node
- Jenkins
- java bigdecimal
- Airflow
- bootstrap
- Kafka
- Spring
- chart.js
- aws cicd
- Flux
- redis
- 도커
- SQL
- or some instances in your deployment group are experiencing problems.
- JavaScript
Archives
- Today
- Total
Small Asteroid Blog
[python] dataframe db에 저장 본문
728x90
import pandas as pd
import pymysql
pymysql.install_as_MySQLdb()
pd_data = pd.DataFrame(resultlist)
print(pd_data)
engine = create_engine('mysql://root:'+'password'+'@localhost/db_name',encoding='utf-8')
pd_data.to_sql('table_name',engine,if_exists='replace',index=False, index_label=None, chunksize=500)
print('ok')
'if_exists' 옵션에는 {'fail', 'replace', 'append'}의 3개가 존재하고, 디폴트는 'fail' 옵션입니다.
- if_exists = 'fail' : 같은 이름의 Table이 존재할 경우 ValueError 가 남
- if_exists = 'replace': 같은 이름의 Table이 존재할 경우 기존 Table을 Drop하고 새로운 값을 Insert함
- if_exists = 'append': 같은 이름의 Table이 존재할 경우 기존 Table에 추가로 새로운 값을 Insert함
728x90
반응형
'백엔드 > Python' 카테고리의 다른 글
[python] No module named 'torch' (0) | 2020.10.29 |
---|---|
[python] No module named 'cv2' (0) | 2020.10.29 |
[python error] not enough arguments for format string (0) | 2020.09.28 |
[python error] execute() takes from 2 to 3 positional arguments but 6 were given (0) | 2020.09.28 |
(오류) (pymysql.err.OperationalError) (1054, "Unknown column '컬럼명' in 'field list'") (0) | 2020.09.28 |