栏目分类:
子分类:
返回
文库吧用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
文库吧 > IT > 面试经验 > 面试问答

使用FreeTDS的Pyodbc连接字符串的SqlAlchemy等效项

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用FreeTDS的Pyodbc连接字符串的SqlAlchemy等效项

@Singletoned的示例不适用于SQLAlchemy 0.7.2。从用于连接到SQL
Server
的SQLAlchemy文档中:

If you require a connection string that is outside the options presentedabove, use the odbc_connect keyword to pass in a urlenpred connection string.What gets passed in will be urldepred and passed directly.

因此,为了使它起作用,我使用了:

import urllibquoted = urllib.quote_plus('DRIVER={FreeTDS};Server=my.db.server;Database=mydb;UID=myuser;PWD=mypwd;TDS_Version=8.0;Port=1433;')sqlalchemy.create_engine('mssql+pyodbc:///?odbc_connect={}'.format(quoted))

这也应适用于Sybase。

注意:在python 3中,urllib模块已拆分为多个部分并重命名。因此,python 2.7中的这一行:

quoted = urllib.quote_plus

必须在python3中更改为这一行:

quoted = urllib.parse.quote_plus


转载请注明:文章转载自 www.wk8.com.cn
本文地址:https://www.wk8.com.cn/it/640023.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 wk8.com.cn

ICP备案号:晋ICP备2021003244-6号