File size: 17,416 Bytes
cf95459
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "84513081",
   "metadata": {},
   "source": [
    "## 查看数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "23241985",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-10-10T12:10:53.493078Z",
     "start_time": "2023-10-10T12:10:53.417598Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<pymysql.connections.Connection object at 0x106d22760>\n",
      "(5, '孙铭阳', '男', 20, '广东', '23446523', '23446523@qq.com', 'zhangsan', '123')\n",
      "(17, '李四', '女', 26, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(21, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(22, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(25, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(27, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(28, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(29, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(30, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(31, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(32, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(33, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(34, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(35, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(36, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(37, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(38, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(39, '李永波', '女', 43, '广东', '236543', '236543@qq.com', None, None)\n",
      "(40, '00', '男', 78, '广东', '99', '123', None, None)\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "\n",
    "## 连接数据库\n",
    "# 获取连接\n",
    "connection = pymysql.connect(\n",
    "    host=\"localhost\", user=\"root\", password=\"zxydsg123\", \n",
    "    db=\"User_information_case\", # 数据库名称\n",
    "    charset='utf8') # 编码 UTF-8\n",
    "\n",
    "print(connection)\n",
    "\n",
    "# 创建 cursor对象\n",
    "cursor = connection.cursor()\n",
    "\n",
    "# 编写 sql\n",
    "sql = \"select * from user\"\n",
    "\n",
    "# 执行 SQL\n",
    "cursor.execute(sql)\n",
    "\n",
    "# 获取结果集\n",
    "users = cursor.fetchall()\n",
    "\n",
    "# 查看结果\n",
    "for u in users:\n",
    "    print(u)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ebb6eacc",
   "metadata": {},
   "source": [
    "## 插入数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "eb638782",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-10-10T12:15:52.983647Z",
     "start_time": "2023-10-10T12:15:52.960757Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "count:  1\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "\n",
    "# 获取连接\n",
    "connection = pymysql.connect(\n",
    "    host=\"localhost\", user=\"root\", password=\"zxydsg123\",\n",
    "    db=\"User_information_case\", # 数据库名称\n",
    "    charset=\"utf8\") # 编码 UTF-8\n",
    "\n",
    "# 获取cursor对象\n",
    "cursor = connection.cursor()\n",
    "\n",
    "# 编写sql\n",
    "sql = \"insert into user(id, name) values(41, 'Tom')\"\n",
    "\n",
    "# 执行sql,返回 影响的行数\n",
    "count = cursor.execute(sql)\n",
    "\n",
    "print(\"count: \", count)\n",
    "\n",
    "# 执行DML时候,会开启一个事务,需要我们主动提交 -- 防止对数据进行误操作\n",
    "connection.commit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4e53b475",
   "metadata": {},
   "source": [
    "## 修改数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "af994da0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-10-10T12:18:28.072611Z",
     "start_time": "2023-10-10T12:18:28.062564Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "count: 1\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "\n",
    "# 获取连接\n",
    "connection = pymysql.connect(\n",
    "    host=\"localhost\", user=\"root\", password=\"zxydsg123\", \n",
    "    db=\"User_information_case\", # 数据库名称\n",
    "    charset=\"utf8\") # 编码 UTF-8\n",
    "\n",
    "# 获取cursor对象\n",
    "cursor = connection.cursor()\n",
    "\n",
    "# 编写sql\n",
    "sql = \"update user set gender='男' where id=41\"\n",
    "\n",
    "# 执行sql,返回受影响的行数\n",
    "count = cursor.execute(sql)\n",
    "print(\"count:\", count)\n",
    "\n",
    "# 执行DML时候,会开启一个事务,需要我们主动提交 -- 防止对数据进行误操作\n",
    "connection.commit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7155a879",
   "metadata": {},
   "source": [
    "## 删除数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "985d4f0b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-10-10T12:20:45.873650Z",
     "start_time": "2023-10-10T12:20:45.864234Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "count: 1\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "\n",
    "# 获取连接\n",
    "connection = pymysql.connect(\n",
    "    host=\"localhost\", user=\"root\", password=\"zxydsg123\", \n",
    "    db=\"User_information_case\", # 数据库名称\n",
    "    charset=\"utf8\") # 编码 UTF-8\n",
    "\n",
    "# 获取cursor对象\n",
    "cursor = connection.cursor()\n",
    "\n",
    "# 编写sql\n",
    "sql = \"delete from user where id=41\"\n",
    "\n",
    "# 执行sql,返回受影响的行数\n",
    "count = cursor.execute(sql)\n",
    "print(\"count:\", count)\n",
    "\n",
    "# 执行DML时候,会开启一个事务,需要我们主动提交 -- 防止对数据进行误操作\n",
    "connection.commit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "56bce4d3",
   "metadata": {},
   "source": [
    "## 查询漏洞"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "29422cfe",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-10-10T12:24:40.726658Z",
     "start_time": "2023-10-10T12:24:40.717935Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "count: 19\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "# 获取连接\n",
    "connection = pymysql.connect(\n",
    "    host=\"localhost\", user=\"root\", password=\"zxydsg123\", \n",
    "    db=\"User_information_case\", # 数据库名称\n",
    "    charset=\"utf8\") # 编码 UTF-8\n",
    "\n",
    "# 获取cursor对象\n",
    "cursor = connection.cursor()\n",
    "\n",
    "# 编写sql\n",
    "sql = \"select * from user where name=%s\" % (\"'scott' or 1=1\")\n",
    "\n",
    "# 执行sql\n",
    "count = cursor.execute(sql)\n",
    "print(\"count:\", count)\n",
    "\n",
    "# 执行DML时候,会开启一个事务,需要我们主动提交 -- 防止对数据进行误操作\n",
    "connection.commit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "706a683b",
   "metadata": {},
   "source": [
    "## 传递参数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a468b121",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-10-10T12:26:10.322260Z",
     "start_time": "2023-10-10T12:26:10.310338Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "count: 1\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "# 获取连接\n",
    "connection = pymysql.connect(\n",
    "    host=\"localhost\", user=\"root\", password=\"zxydsg123\", \n",
    "    db=\"User_information_case\", # 数据库名称\n",
    "    charset=\"utf8\") # 编码 UTF-8\n",
    "\n",
    "# 获取cursor对象\n",
    "cursor = connection.cursor()\n",
    "\n",
    "# 编写sql\n",
    "sql = \"insert into user(id, name) values(%s, %s)\"\n",
    "\n",
    "# 执行sql\n",
    "args = (41, 'marry')\n",
    "count = cursor.execute(sql, args)\n",
    "print(\"count:\", count)\n",
    "\n",
    "# 执行DML时候,会开启一个事务,需要我们主动提交 -- 防止对数据进行误操作\n",
    "connection.commit()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "84a00649",
   "metadata": {},
   "source": [
    "## 添加异常处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "d24cf6a9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-10-10T12:32:36.642368Z",
     "start_time": "2023-10-10T12:32:36.630347Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "count: 1\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "connection = None\n",
    "cursor = None\n",
    "\n",
    "try:\n",
    "    # 获取连接\n",
    "    connection = pymysql.connect(\n",
    "        host=\"localhost\", user=\"root\", password=\"zxydsg123\", \n",
    "        db=\"User_information_case\", # 数据库名称\n",
    "        charset=\"utf8\") # 编码 UTF-8\n",
    "    \n",
    "    # 获取 cursor对象\n",
    "    cursor = connection.cursor()\n",
    "    \n",
    "    # 编写sql\n",
    "    sql = \"insert into user(id, name) values(%s, %s)\"\n",
    "    \n",
    "    # 执行sql\n",
    "    args = (1234, 'Tom')\n",
    "    count = cursor.execute(sql, args)\n",
    "    print(\"count:\", count)\n",
    "    \n",
    "    # 执行DML时候,会开启一个事务,需要我们主动提交\n",
    "    connection.commit()\n",
    "    \n",
    "except Exception as e:\n",
    "    # 如果捕获到异常\n",
    "    print(e)\n",
    "    \n",
    "    if connection:\n",
    "        # 回滚事务\n",
    "        connection.rollback()\n",
    "        \n",
    "finally:\n",
    "    # 无论是否捕获到异常,我们都要关闭cursor,释放资源\n",
    "    if cursor:\n",
    "        cursor.close()\n",
    "        \n",
    "    if connection:\n",
    "        cursor.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "874055be",
   "metadata": {},
   "source": [
    "## DBUtil功能封装"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8873d37e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-10-10T12:44:33.199935Z",
     "start_time": "2023-10-10T12:44:33.175199Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1062, \"Duplicate entry '9999' for key 'user.PRIMARY'\")\n",
      "(9999, 'lili', '女', None, None, None, None, None, None)\n",
      "(5, '孙铭阳', '男', 20, '广东', '23446523', '23446523@qq.com', 'zhangsan', '123')\n",
      "(17, '李四', '女', 26, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(21, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(22, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(25, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(27, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(28, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(29, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(30, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(31, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(32, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(33, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(34, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(35, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(36, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(37, '李四', '男', 24, '广东', '12345123', 'lisi@qq.com', None, None)\n",
      "(38, '王五', '男', 25, '湖南', '12345123', 'lisi@qq.com', None, None)\n",
      "(39, '李永波', '女', 43, '广东', '236543', '236543@qq.com', None, None)\n",
      "(40, '00', '男', 78, '广东', '99', '123', None, None)\n",
      "(41, 'marry', None, None, None, None, None, None, None)\n",
      "(1234, 'Tom', None, None, None, None, None, None, None)\n",
      "(9999, 'lili', '女', None, None, None, None, None, None)\n"
     ]
    }
   ],
   "source": [
    "import pymysql\n",
    "\n",
    "\n",
    "class DBUtil:\n",
    "    \"\"\"数据库工具类\"\"\"\n",
    "\n",
    "    config = {\n",
    "        \"host\": \"localhost\",\n",
    "        \"user\": \"root\",\n",
    "        \"password\": \"zxydsg123\",\n",
    "        \"db\": \"User_information_case\",  # 数据库名称\n",
    "        \"charset\": \"utf8\"  # 编码 UTF-8\n",
    "    }\n",
    "\n",
    "    def __init__(self):\n",
    "\n",
    "        # 建立连接,传入参数\n",
    "        self.connection = pymysql.connect(**DBUtil.config)\n",
    "\n",
    "        # 创建 cursor对象\n",
    "        self.cursor = self.connection.cursor()\n",
    "\n",
    "    def close(self):\n",
    "        \"\"\"释放资源\"\"\"\n",
    "        if self.cursor:\n",
    "            self.cursor.close()\n",
    "        if self.connection:\n",
    "            self.connection.close()\n",
    "\n",
    "    def exeDML(self, sql, *args):\n",
    "        \"\"\"DML(Data Manipulation Language)语句: 数据操纵语言 -- 插入 修改  删除调用\"\"\"\n",
    "        try:\n",
    "            # 执行sql,返回影响到的行数\n",
    "            count = self.cursor.execute(sql, args)\n",
    "            \n",
    "            # 提交事务\n",
    "            self.connection.commit()\n",
    "            \n",
    "            return count\n",
    "        \n",
    "        # 如果捕获到异常\n",
    "        except Exception as e:\n",
    "            print(e)\n",
    "            \n",
    "            # 回滚食物\n",
    "            if self.connection:\n",
    "                self.connection.rollback()\n",
    "\n",
    "    def query_one(self, sql, *args):\n",
    "        \"\"\"查询单行数据\"\"\"\n",
    "        try:\n",
    "            # 执行sql\n",
    "            self.cursor.execute(sql, args)\n",
    "            \n",
    "            # 获取结果集\n",
    "            return self.cursor.fetchone()\n",
    "        \n",
    "        except Exception as e:\n",
    "            print(e)\n",
    "    \n",
    "    def query_all(self, sql, *args):\n",
    "        \"\"\"查询所有数据\"\"\"\n",
    "        try:\n",
    "            # 执行sql\n",
    "            self.cursor.execute(sql, args)\n",
    "            # 获取结果集\n",
    "            return self.cursor.fetchall()\n",
    "        \n",
    "        except Exception as e:\n",
    "            print(e)\n",
    "\n",
    "\n",
    "if __name__ == \"__main__\":\n",
    "    \n",
    "    # 创建 DBUtil\n",
    "    dbutil = DBUtil()\n",
    "    \n",
    "    # 插入数据\n",
    "    sql = \"insert into user(id, name, gender) values(%s, %s, %s)\"\n",
    "    \n",
    "    count = dbutil.exeDML(sql, 9999,'lili', '女')\n",
    "\n",
    "    \n",
    "    # 查询单行数据\n",
    "    sql = \"select * from user where id=%s\"\n",
    "\n",
    "    # 打印查询结果\n",
    "    emp = dbutil.query_one(sql, 9999)\n",
    "    print(emp)\n",
    "\n",
    "    \n",
    "    # 查询所有数据\n",
    "    sql = \"select * from user\"\n",
    "    users = dbutil.query_all(sql)\n",
    "    for u in users:\n",
    "        print(u)\n",
    "        \n",
    "    # 记得释放资源\n",
    "    dbutil.close()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.9.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "288px"
   },
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}