免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2196 | 回复: 5
打印 上一主题 下一主题

跪求 django1.1 连接mssql2005 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-08-19 18:15 |只看该作者 |倒序浏览
找了很多文档都没找到合适的,求大家帮帮忙吧,先谢了

论坛徽章:
0
2 [报告]
发表于 2009-08-19 22:25 |只看该作者
yum search

论坛徽章:
0
3 [报告]
发表于 2009-08-20 09:31 |只看该作者
1.0的有,1.1没试过

论坛徽章:
0
4 [报告]
发表于 2009-08-20 17:38 |只看该作者
1.0的也行 贴上来 谢了

论坛徽章:
0
5 [报告]
发表于 2009-08-22 12:43 |只看该作者

论坛徽章:
0
6 [报告]
发表于 2009-08-25 16:01 |只看该作者
import logging
from DBUtils.PooledDB import PooledDB

if not settings.IS_DEV:
    logging.info('mssql dbpool initing!')
#    args = (5,30,0,50,0,0,None)
#    conn_kwargs = {'host':'.', 'user':settings.MSSQL_USER, 'password':settings.MSSQL_PASSWD,'database':settings.MSSQL_DATABASE_NAME,'trusted':True}
#    databaseConnPool = PooledDB(pymssql, *args, **conn_kwargs)
    logging.info('mssql dbpool init end!')

'''
get mssql connection
'
''
def __getConnection():
    conn = None
    try:
        conn = databaseConnPool.connection()
        #pymssql.connect(host=".",user=settings.MSSQL_USER,password=settings.MSSQL_PASSWD,database=settings.MSSQL_DATABASE_NAME,trusted=True)
    except pymssql.MssqlDatabaseException,e:
        if e.number == 2714 and e.severity == 16:
            if conn is not None:conn.close()
            raise Exception, 'connect database has wrong1'
        else:
            if conn is not None:conn.close()
            raise Exception, 'connect database has wrong2'
    return conn


我用了连接池的,先凑合着看吧,以前写的可能有点错误,我用的 import pymssql
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP