Skip to content

Commit

Permalink
Upload New File
Browse files Browse the repository at this point in the history
  • Loading branch information
sarashe committed Aug 10, 2020
1 parent 6e730f5 commit 93969c0
Showing 1 changed file with 99 additions and 0 deletions.
99 changes: 99 additions & 0 deletions pymysql_aws_rds.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Collecting PyMySQL\n",
" Using cached PyMySQL-0.10.0-py2.py3-none-any.whl (47 kB)\n",
"Installing collected packages: PyMySQL\n",
"Successfully installed PyMySQL-0.10.0\n"
]
}
],
"source": [
"!pip install PyMySQL"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
"import pymysql as pms\n",
"import requests\n",
"import base64\n",
"import json\n",
"\n",
"import logging"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"host = \"ict.clw3yf0azeqw.ap-northeast-2.rds.amazonaws.com\"\n",
"port = 3306\n",
"username = \"admin\"\n",
"database = \"ict\"\n",
"password = \"48834883\"\n",
"\n",
"\n",
"try:\n",
" conn = pms.connect(host=host,user=username,password=password,db=database, \n",
" port=port, use_unicode=True, charset=\"utf8\")\n",
" cursor=conn.cursor()\n",
"except:\n",
" logging.error(\"연결 실패\")\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"query = 'insert into precedent (ID,casename) values(\"{0}\",\"{1}\") on duplicate key update ID = \"{0}\", casename = \"{1}\"'.format(111,'사건1')\n",
"cursor.execute(query)\n",
"conn.commit()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit 93969c0

Please sign in to comment.