
- Python SQLite 教程
- Python SQLite - 主頁
- Python SQLite - 簡介
- Python SQLite - 建立連線
- Python SQLite - 建立表
- Python SQLite - 插入資料
- Python SQLite - 選擇資料
- Python SQLite - Where 子句
- Python SQLite - 按順序排列
- Python SQLite - 更新表
- Python SQLite - 刪除資料
- Python SQLite - 刪除表
- Python SQLite - 限制
- Python SQLite - 聯接
- Python SQLite - 遊標物件
- Python SQLite 有用資源
- Python SQLite - 快速指南
- Python SQLite - 有用資源
- Python SQLite - 討論
Python SQLite - 建立連線
要透過 SQLite 建立連線,請開啟命令提示符,瀏覽你安裝 SQLite 的位置,然後執行命令 sqlite3,如下所示 −

使用 Python 建立連線
你可以使用 Python 模組 SQLite3 與 SQLite2 資料庫進行通訊。首先,你需要建立連線(建立一個連線物件)。
要使用 Python 與 SQLite3 資料庫建立連線,你需要 −
使用 import 語句匯入 sqlite3 模組。
connect() 方法接受要連線的資料庫的名稱作為引數,並返回一個連線物件。
示例
import sqlite3 conn = sqlite3.connect('example.db')
輸出
print("Connection established ..........")
廣告