惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - XiaoHui

windbg tips windbg无法下载pdb调试符号 unix/linux tips freebsd中xorg 7.4键盘反应迟顿的问题 Django升级到1.0以后的一些变化 ubuntu安装新字体 诡异的修改首页--00333.cn/alei.htm 使用nmap扫描内网在线机器的MAC地址 [转载]HOWTO 使用 vim 的 minibuf 来切换缓冲区 - XiaoHui rtorrent无法完全支持中文的解决办法 EFLAGES寄存器中的系统标志 How to manually create a crash dump file 因网络限制而无法连接MS的symbol服务器的解决办法 NEG+SBB指令组合的用处 Nt*与Zw*的区别 Image与Base64String的互转换 编程实现清除temp1.exe,temp2.exe木马 类似Acdsee的东东,不过是用.NET的。 AIHear 0.1.2
python连接数据库
XiaoHui · 2009-09-08 · via 博客园 - XiaoHui

postgresql:

使用psycopg2来连接

示例代码:

1 import psycopg2
2 
3 conn = psycopg2.connect("dbname='dbname' user='username' host='localhost' password='password'")
4 cur = conn.cursor()
5 cur.execute("select * from dbtable")
6 for row in cur:
7     print row[0]
8 conn.close()

ms sql server:

使用pymssql来连接

示例代码:

 1 import psmssql
 2 
 3 conn = psmssql.connect(host='yourhost', user='loginname', password='password', database='dbname', charset='utf8')
 4 cur = conn.cursor()
 5 cur.execute('select * from dbtable')
 6 
 7 for row in cur:
 8     print row[0]
 9 
10 conn.close()