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

推荐订阅源

The GitHub Blog
The GitHub Blog
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
V
Vulnerabilities – Threatpost
S
Secure Thoughts
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Threat Research - Cisco Blogs
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
AWS News Blog
AWS News Blog
C
CERT Recently Published Vulnerability Notes
博客园 - 【当耐特】
量子位
有赞技术团队
有赞技术团队
腾讯CDC
P
Proofpoint News Feed
小众软件
小众软件
T
Tor Project blog
Cisco Talos Blog
Cisco Talos Blog
博客园 - 三生石上(FineUI控件)
L
LINUX DO - 热门话题
人人都是产品经理
人人都是产品经理
罗磊的独立博客
M
MIT News - Artificial intelligence
阮一峰的网络日志
阮一峰的网络日志
爱范儿
爱范儿
A
About on SuperTechFans
月光博客
月光博客
G
GRAHAM CLULEY
P
Privacy & Cybersecurity Law Blog
P
Palo Alto Networks Blog
K
Kaspersky official blog
Latest news
Latest news
C
Cisco Blogs
I
Intezer
L
Lohrmann on Cybersecurity
Apple Machine Learning Research
Apple Machine Learning Research
aimingoo的专栏
aimingoo的专栏
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Martin Fowler
Martin Fowler
Engineering at Meta
Engineering at Meta
P
Privacy International News Feed
Scott Helme
Scott Helme
Google DeepMind News
Google DeepMind News
S
Security @ Cisco Blogs
T
The Blog of Author Tim Ferriss
S
Securelist
PCI Perspectives
PCI Perspectives
V
Visual Studio Blog
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - 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()