jupyterlab
jupyterlab项目
This commit is contained in:
commit
ad0d0a5396
11 files changed
+6187
No files matched your search
+130
@@ -0,0 +1,130 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"db = pymysql.connect(\"localhost\",\"songyi\",\"yylzs\",\"mydata\" )\n",
|
||||
"cursor = db.cursor()\n",
|
||||
"cursor.execute(\"SELECT VERSION()\")\n",
|
||||
"data = cursor.fetchone()\n",
|
||||
"print (\"Database version : %s \" % data)\n",
|
||||
"db.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"db = pymysql.connect(\"localhost\",\"songyi\",\"yylzs\",\"mydata\" )\n",
|
||||
"cursor = db.cursor()\n",
|
||||
"sql = \"select id,name from sports_person where name= %s\"\n",
|
||||
"cursor.execute(sql, ('张联红',))\n",
|
||||
"result = cursor.fetchone()\n",
|
||||
"print(result)\n",
|
||||
"db.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"db = pymysql.connect(\"localhost\",\"songyi\",\"yylzs\",\"mydata\" )\n",
|
||||
"cursor = db.cursor()\n",
|
||||
"sql = \"select id,name from sports_person\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"result = cursor.fetchone()\n",
|
||||
"print(\"人员信息:\")\n",
|
||||
"print(result)\n",
|
||||
"sql = \"select id,name from sports_item\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"result = cursor.fetchone()\n",
|
||||
"print(\"\\n运动项目信息:\")\n",
|
||||
"print(result)\n",
|
||||
"db.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"db = pymysql.connect(\"localhost\",\"songyi\",\"yylzs\",\"mydata\" )\n",
|
||||
"cursor = db.cursor()\n",
|
||||
"sql = \"select a.target_id,b.name from sports_item_target as a,sports_target as b where a.target_id=b.id\"\n",
|
||||
"cursor.execute(sql)\n",
|
||||
"re_ta = {}\n",
|
||||
"print(\"\\n运动项目信息:\")\n",
|
||||
"results = cursor.fetchall()\n",
|
||||
"for result in results:\n",
|
||||
"# print (\"%d--%s\" %(result[0],result[1]))\n",
|
||||
" re_ta[result[0]] = result[1]\n",
|
||||
" print(\"re_ta[%d]= #%s\" %(result[0],result[1]))\n",
|
||||
"print(re_ta)\n",
|
||||
"db.close()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pymysql\n",
|
||||
"db = pymysql.connect(\"localhost\",\"songyi\",\"yylzs\",\"mydata\" )\n",
|
||||
"cursor = db.cursor()\n",
|
||||
"person_id = \n",
|
||||
"record_date = ''\n",
|
||||
"item_id =\n",
|
||||
"re_ta = {}\n",
|
||||
"re_ta[1]= #运动距离\n",
|
||||
"re_ta[2]= #运动时间\n",
|
||||
"re_ta[3]= #平均配速\n",
|
||||
"re_ta[4]= #平均速度\n",
|
||||
"re_ta[5]= #平均步频\n",
|
||||
"re_ta[6]= #平均步幅\n",
|
||||
"re_ta[7]= #步数\n",
|
||||
"re_ta[8]= #平均心率\n",
|
||||
"re_ta[9]= #最大心率\n",
|
||||
"re_ta[10]= #无氧耐力\n",
|
||||
"re_ta[11]= #有氧耐力\n",
|
||||
"re_ta[12]= #最大步频\n",
|
||||
"re_ta[13]= #最快配速\n",
|
||||
"sql = \"select * from sports_person\"\n",
|
||||
"db.close()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"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.8.5"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
||||
Reference in new issue
Block a user