PyMySQL
Preset
Install package
pip install pymysql
PyMySQL
| 變述及函數 | 用途 |
|---|---|
| conn = pymysql.connect(…) | 與資料庫建立連線,conn為資料庫連線物件 |
| cursor = conn.cursor() | 建立資料庫游標物件cursor |
| cursor.execute(s) | 執行SQL指令s |
| cursor.executemany(s, [(…), (…), …]) | 批量執行SQL指令 |
| cursor.fetchone() | 獲取下一筆查詢結果 |
| cursor.fetchmany(n) | 獲取n筆查詢結果 |
| cursor.fetchall() | 獲取所有查詢結果 |
| cursor.close() | 關閉游標 |
| conn.close() | 關閉連線 |
