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 |
Tags
- version_error
- 깃
- Python
- 선형회귀
- 깃허브
- TensorFlow
- tf.where
- AI #RNN #LSTM #LSTMP #인공지능 #언어학습 #순차학습
- 특정값지우기
- Asyncio
- pandas #python #date #datetime
- AI #Inductive_Bias #Relational_inductive_bias
- 시계열데이터
- git
- fashionmnist
- Github
- MachineLearning
- mnist
- ngrok
- tensorflow #tensorflow-gpu #python #ubuntu #텐서플로우
- 파이썬
- aiohttp
- pandas #ewma #python #지수이동가중평균 #파이썬 #판다스 #ema #ewm
- REST_API
- 비동기모듈
- SQL #PostgreSQL
- SQL #python #MySQL #PostgreSQL
- 판다스 #Pandas #DataFrame #Statistics #통계 #파이썬 #Python #Resample
- python #pandas #data_preprocessing #data_process
- pandas #python #excel #판다스 #파이썬 #엑셀저장 #xlsxwriter
Archives
- Today
- Total
린스토리
[MySQL / PostgreSQL] python & pandas와 연동하기 본문
SQL을 python과 연동해서 작업하면 훨씬 수월하다.
우선 MySQL을 python과 연동하는 법을 알아보자.
MySQL 라이브러리 설치
pip install pymysql
MySQL을 python과 연동하기
import pymysql
conn = pymysql.connect(host='host', user='user', port=port, password='password', db='db')
PostgreSQL 연동도 이와 비슷하다.
PostgreSQL 라이브러리 설치
pip install psycopg2
PostgreSQL을 python과 연동하기
import psycopg2 as pg
conn = pg.connect(host='host', user='user', port=port, password='password', dbname='dbname')
MySQL / PostgreSQL 저장된 데이터 테이블 pandas로 불러오기
sql = 'SELECT * FROM [table_name];'
#방법1
import pandas as pd
df = pd.read_sql_query(sql, conn)
#방법2
import pandas.io.sql as psql
df = psql.read_sql(sql, conn)
'SQL' 카테고리의 다른 글
| [PostgreSQL] 가장 오래된/최근 데이터 가져오기 (0) | 2022.06.21 |
|---|
Comments