
- Python PostgreSQL 教程
- Python PostgreSQL - 主頁
- Python PostgreSQL - 介紹
- Python PostgreSQL - 資料庫連線
- Python PostgreSQL - 建立資料庫
- Python PostgreSQL - 建立表
- Python PostgreSQL - 插入資料
- Python PostgreSQL - 選擇資料
- Python PostgreSQL - Where 子句
- Python PostgreSQL - Order By
- Python PostgreSQL - 更新表
- Python PostgreSQL - 刪除資料
- Python PostgreSQL - 刪除表
- Python PostgreSQL - Limit
- Python PostgreSQL - Join
- Python PostgreSQL - 遊標物件
- Python PostgreSQL 有用資源
- Python PostgreSQL - 快速指南
- Python PostgreSQL - 有用資源
- Python PostgreSQL - 討論
Python PostgreSQL - 介紹
PostgreSQL 是一款強大的開源物件關聯資料庫系統。它有超過 15 年的活躍開發階段,經過驗證的架構為其贏得了在可靠性、資料完整性和正確性方面的良好聲譽。
要使用 Python 與 PostgreSQL 通訊,你需要為 Python 程式設計安裝 psycopg,它是為此提供的介面卡,它的當前版本是psycog2。
psycopg2 寫作的目的是要讓它非常小、快速、穩定。它可以在 PIP(python 的軟體包管理器)中找到
使用 PIP 安裝 Psycog2
首先,確保 Python 和 PIP 已正確安裝在你的系統中,而且 PIP 是最新的。
要升級 PIP,開啟命令提示符並執行以下命令 −
C:\Users\Tutorialspoint>python -m pip install --upgrade pip Collecting pip Using cached https://files.pythonhosted.org/packages/8d/07/f7d7ced2f97ca3098c16565efbe6b15fafcba53e8d9bdb431e09140514b0/pip-19.2.2-py2.py3-none-any.whl Installing collected packages: pip Found existing installation: pip 19.0.3 Uninstalling pip-19.0.3: Successfully uninstalled pip-19.0.3 Successfully installed pip-19.2.2
然後,在管理員模式下開啟命令提示符並執行pip install psycopg2-binary 命令,如下所示 −
C:\WINDOWS\system32>pip install psycopg2-binary Collecting psycopg2-binary Using cached https://files.pythonhosted.org/packages/80/79/d0d13ce4c2f1addf4786f4a2ded802c2df66ddf3c1b1a982ed8d4cb9fc6d/psycopg2_binary-2.8.3-cp37-cp37m-win32.whl Installing collected packages: psycopg2-binary Successfully installed psycopg2-binary-2.8.3
驗證
要驗證安裝,建立一個示例 Python 指令碼,其中包含以下行。
import mysql.connector
如果安裝成功,當你執行它時,你不應收到任何錯誤 −
D:\Python_PostgreSQL>import psycopg2 D:\Python_PostgreSQL>
廣告