1

I am trying to get the date datatype from SQLserver 2014 as native python date through pymssql. Based on pymssql doc, I need to have 0.95+ freetds lib and 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

And I made following config:

#/etc/freetds.conf
[sqlsvr1]
    host = sqlsvr1
    port = 1433
    tds version = 7.3

And I still get python string instead of date. This is from the TDSDUMPCONFIG. Is it because freetds 0.95.8 does not support tds 7.3? (The major/minor version seem to have been replace to 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 =

If I set the tds version to 7.4 in the config, then I notice this error in the log:

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

Env: Linux/RH 6 + Python3.4.3 + pymssql(2.1.1) all x64

Any suggestions?

3
  • 1
    Have you tried explicitly specifying the TDS version in your .connect call to see if that makes a difference? e.g., pymssql.connect(server='sqlsvr1', port='1433', ... , tds_version='7.3') Commented Aug 26, 2016 at 20:23
  • It shows on your FreeTDS config that it's using unixODBC. If you're not specifying the tds_version in the connection string, be sure to also put it in your odbc.ini file DNS: TDS_Version = 7.2 Commented Aug 27, 2016 at 17:30
  • Have you figureout how to change major and minor version for TDS ? Commented May 31, 2019 at 21:31

1 Answer 1

2

You have most of the required pieces.

But the one missing is the fact you are using pymssql 2.1.1.

Support for the DATE and TIME data types is implemented but targeted for pymssql 2.2.0 which isn't released yet. If you need it now you'll need to build it yourself from the 'master' Git branch first.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! What's the estimated release date for 2.2.0?
Thank you, that fixed my problem also. You still need to install from Git as of today (2017-07-20), newest pymssql 2.2 has not yet been released.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.