我试图通过pymssql从SQLserver 2014获取日期数据类型作为本机python日期。基于pymssql doc,我需要拥有0.95+ freetds lib和7.3 freetds ver。
# tsql -C
Compile-time settings (established with the "configure" script)
Version: freetds v0.95.8
freetds.conf directory: /etc
MS db-lib source compatibility: no
Sybase binary compatibility: no
Thread safety: yes
iconv library: yes
TDS version: 4.2
iODBC: no
unixodbc: yes
SSPI "trusted" logins: no
Kerberos: no
OpenSSL: no
GnuTLS: no
我做了以下配置:
#/etc/freetds.conf
[sqlsvr1]
host = sqlsvr1
port = 1433
tds version = 7.3
我仍然得到python字符串而不是日期。这来自TDSDUMPCONFIG。是因为freetds 0.95.8不支持tds 7.3吗? (主要/次要版本似乎已取代7/1)。
config.c:620:IP addr is 172.16.12.26.
config.c:580: port = '1433'
config.c:580: tds version = '7.3'
config.c:886:Setting tds version to 7.3 (0x703).
config.c:568: Reached EOF
config.c:300:Success: [sqlsvr1] defined in /etc/freetds.conf.
config.c:765:Setting 'dump_file' to '/tmp/freetds.log' from $TDSDUMP.
config.c:689:tds_config_login: client_charset is UTF-8.
config.c:213:Final connection parameters:
config.c:214: server_name = sqlsvr1:1433
config.c:215: server_host_name = sqlsvr1
config.c:218: ip_addr = 172.16.12.26
config.c:218: ip_addr = 172.16.12.26
config.c:218: ip_addr = 172.16.12.26
config.c:223: instance_name =
config.c:224: port = 1433
config.c:225: major_version = 7
config.c:226: minor_version = 1
config.c:227: block_size = 0
config.c:228: language = us_english
config.c:229: server_charset =
config.c:230: connect_timeout = 0
config.c:231: client_host_name = rh1.int
config.c:232: client_charset = UTF-8
config.c:233: use_utf16 = 0
config.c:234: app_name = pymssql
config.c:235: user_name = USER
config.c:238: library = DB-Library
config.c:239: bulk_copy = 0
config.c:240: suppress_language = 0
config.c:241: encrypt level = 0
config.c:242: query_timeout = 0
config.c:245: database =
config.c:246: dump_file = /tmp/freetds.log
config.c:247: debug_flags = 0
config.c:248: text_size = 64512
config.c:249: emul_little_endian = 0
config.c:250: server_realm_name =
config.c:251: server_spn =
config.c:252: cafile =
config.c:253: crlfile =
如果我在配置中将tds版本设置为7.4,那么我会在日志中注意到这个错误:
config.c:580: tds version = '7.4'
config.c:881:error: no such version: 7.4
config.c:568: Reached EOF
config.c:213:Final connection parameters:
... ...
config.c:225: major_version = 7
config.c:226: minor_version = 1
环境:Linux / RH 6 + Python3.4.3 + pymssql(2.1.1)全部x64
有什么建议吗?
答案 0 :(得分:2)
你有大部分所需的作品。
但缺少的是您正在使用pymssql 2.1.1。
已实现对DATE和TIME数据类型的支持,但针对尚未发布的pymssql 2.2.0。如果你现在需要它,你需要先从'master'Git分支自己构建它。