win 下python2.7 pymssql连接ms sqlserver 2000
python DB-API 连接mysql 要用到库pymssql 下载请到https://pypi.python.org/pypi/pymssql/2.0.1我这里下载的是ms windows installer版本exe文件,直接运行就可以了,whl和egg格式的看不懂怎么安装.
下载完,试着连接到本机的pubwin数据库写了一句查询,很方便的样子
# -*- coding:gbk -*-
import pymssql
try:
con=pymssql.connect(host='.',user='sa',password='sa',database='local')
cur=con.cursor()
cur.execute('select uniqueid,levelid from mem_localmemberbaseinfo')
for uniqueid,levelid in cur.fetchall():
print 'uniqueid: %s,levelid: %s' % (uniqueid,levelid)
print cur.rowcount
cur.close()
con.close() except:
print 'sql Error'
con=pymssql.connect(host='.',user='sa',password='sa',database='local'),百度了一下,python DB-API连接数据库都是用这个格式标准。host可以用ip:1433的格式 带端口。
fetchall():用来取回cur的所有数据,fetchone 是只取回一行数据,上面的查询,同样可以用detchone实现:
# -*- coding:gbk -*-
import pymssql
try:
con=pymssql.connect(host='127.0.0.1:1433',user='sa',password='sa',database='local')
cur=con.cursor()
cur.execute('select uniqueid,levelid from mem_localmemberbaseinfo order by uniqueid')
rowcount=0
while 1:
row=cur.fetchone()
if row==None:break
print "uniqueid: %s,levelid %s" % (row[0],row[1])
rowcount+=1
print rowcount
cur.close()
con.close() except:
print 'sql Error'
参考:http://tech.it168.com/a2009/1014/759/000000759444.shtml(利用MySQLdb 对DB-API的详细介绍,推荐)
win 下python2.7 pymssql连接ms sqlserver 2000的更多相关文章
- Linux下PHP连接MS SQLServer的办法
Linux下PHP连接MS SQLServer的办法分析问题 本来PHP脚本读写SQLServer是没有什么问题的,在Apache for windows和Windows IIS下可以工作的很好,一般 ...
- php 5.4 5.5 如何连接 ms sqlserver
https://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx
- MS SQLSERVER中如何快速获取表的记录总数
在数据库应用的设计中,我们往往会需要获取某些表的记录总数,用于判断表的记录总数是否过大,是否需要备份数据等.我们通常的做法是:select count(*) as c from tableA .然而对 ...
- Linux下通过JDBC连接Oracle,SqlServer和PostgreSQL
今天正好需要统计三个网站栏目信息更新情况,而这三个网站的后台采用了不同的数据库管理系统.初步想法是通过建立一个小的Tomcat webapp,进而通过JDBC访问这三个后台数据库,并根据返回的数据生成 ...
- c# 使用MS SqlServer,连接成功,但是还报异常A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0。。。。
c# 使用MS SqlServer,连接成功,但是还报异常A connection was successfully established with the server, but then an ...
- Windos 下python2.7安装 pymssql 解决方案
最近在学python,到安装pymssql这一块遇到了不少问题. 第一:如何安装python 模块,也是最主要的问题. 可以这么理解:在安装python其它模块之前,可以先安装一个负责安装模块的模块. ...
- 通过win下的eclipse连接虚拟机中伪分布的hadoop进行调试
VMware虚拟机配置Ubuntu桥接方式(Bridged)使虚拟机和宿主机能互相ping通, 通过win下的eclipse连接虚拟机中伪分布的hadoop进行调试 1.设置Bridged上网方式 V ...
- oracle直接读写ms sqlserver数据库(二)配置透明网关
环境说明: 数据库版本:11gR2 透明网关版本:11g 操作系统Windows Server2008_64位 ORACLE_HOME目录:D:\app\Administrator\product\1 ...
- pymssql连接Azure SQL Database
使用pymssql访问Azure SQL Database时遇到"DB-Lib error message 20002, severity 9:\nAdaptive Server conne ...
随机推荐
- WORD-如何解除WORD文档的锁定
Word文档保护破解 般来说WORD文档有两种密码打开密码和文档保护密码下面介绍几种破解文档保护密码方法 方法1:插入文件法 启动WORD新建空白文档执行插入→文件打开插入文件对框定位需要解除保护文档 ...
- Form表单插件jquery.form.js
常常使用到这个插件,但是老忘记怎么使用,现在对大家写的进行一定的整合. 使用插件实例: 一般的使用方法 <!-- 引入jquery文件 --> <script src="h ...
- 使用UEditor
在http://ueditor.baidu.com/website/上下载官方文件 文本编辑器的配置文件在ueditor.config.js 需要注意一下几点 首先 var URL = window. ...
- Android 之 ExpandableListView 的使用
喜欢显示好友QQ那样的列表,可以展开,可以收起,在android中,以往用的比较多的是listview,虽然可以实现列表的展示,但在某些情况下,我们还是希望用到可以分组并实现收缩的列表,那就要用到an ...
- Atitit.软件guibuttonand面板---os区-----linux windows搜索文件 目录
Atitit.软件guibuttonand面板---os区-----搜索文件 1. Find 1 2. 寻找文件夹 1 3. 2. Locate// everything 1 4. 3. Wherei ...
- Vijos1051. 送给圣诞夜的极光
试题请參见: https://vijos.org/p/1051 题目概述 圣诞老人回到了北极圣诞区, 已经快到12点了. 也就是说极光表演要開始了. 这里的极光不是极地特有的自然极光景象. 而是圣诞老 ...
- MySQL学习笔记:MySQL: ERROR 1064(42000)
ERROR 1064 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL s ...
- C#调用WebService实例和开发
一.基本概念 Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求,轻量级的独立的通讯技术.是 ...
- android——ImageLoader添加缓存
//给图片加入到缓存中. DisplayImageOptions options = new DisplayImageOptions.Builder().cacheOnDisc( ...
- 一个Demo就懂的Angular之directive
<body> <div ng-controller="myCtrl"> <hello-word></hello-word> < ...