python与数据数据库

pyodbc

连接字符串: conn = pyodbc.connect(Driver={SQL Server};Server=127.0.0.1;Database=dbname;Uid=sa;pwd=sa;autocommit=true)

download:pymssql,文档:http://pymssql.sourceforge.net/documentation.php

连接字符串:conn = pymssql.connect(host='192.168.31.99', database='gvss_sale', user='gvss', password='gvss')

pymssql的限制:

  • image data is truncated to 4000 characters.
    This is known limitation of DB-Library for C. I know of no workaround. This issue is also present in PHP, the solution suggested was to use ODBC protocol.

  • varchar and nvarchar data is limited to 255 characters, and longer strings are silently trimmed.
    This is known limitation of TDS protocol. A workaround is to CAST or CONVERT that row or expression totext data type, which is capable of returning4000 characters.

  • column names are limited to 30 characters and longer names are silently truncated.
    There's no workaround for this. You have to use names (or aliases as in SELECT columnAS alias) that are not longer than 30 characters.

  • "SELECT ''" statement returns a string containing one space instead of an empty string.
    There's no workaround for this. You cannot distinguish between
        SELECT ''   -- empty string
    and
        SELECT ' '  -- one space

  • "SELECT CAST(NULL AS BIT)" returns False instead of None.
    There's no workaround for this. You cannot distinguish between
        SELECT CAST(NULLAS BIT)
    and
        SELECT CAST(0AS BIT)

    You should avoid NULL bit fields.Just assign a default value to them and update all records to the default value.I would recommend not usingBIT datatype at all, if possible change it to TINYINT for example.The problem will disappear, and storage overhead is unnoticeable.This issue is also known for example in Microsoft's own product, Access, seeKB278696 article.

  • New features of SQL Server 2005 and SQL Server 2008 are not supported.
    Some of the features of SQL Server versions newer than 2000 just don't work.For example you can't use MARS feature (Multiple Active Result Sets). You haveto arrange your queries so that result sets are fetched one after another.

  • The newest version of ntwdblib.dll library v. 2000.80.2273.0 is unusable.
    If on Windows, please use the library bundled with pymssql package. Older or newer versionsmay introduce unexpected problems, the version mentioned above causes memory violation errors,but only in certain scenarios, making tracing the cause very difficult. More information is also available on FAQ page.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值