File: README.freetds

package info (click to toggle)
pymssql 0.8.0%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 160 kB
  • ctags: 196
  • sloc: ansic: 877; python: 409; makefile: 5
file content (33 lines) | stat: -rw-r--r-- 1,703 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
SUMMARY: MAKE SURE FREETDS IS COMPILED WITH --enable-msdblib OPTION. OR YOUR
	 QUERIES MAY RETURN WRONG DATES - 2005-00-01 INSTEAD OF 2005-01-01.

There's an obscure problem on *nix that results in dates shifted back by 1
month. This behaviour is caused by different dbdatecrack() prototypes in
Sybase Open Client DB-Library/C and the MS SQL DB Library for C. The first
one returns month as 0..11 whereas the second gives month as 1..12. See
<http://lists.ibiblio.org/pipermail/freetds/2002q3/008336.html>,
<http://msdn.microsoft.com/library/en-us/dblibc/dbc_pdc04c_4uqz.asp>,
<http://manuals.sybase.com/onlinebooks/group-cnarc/cng1110e/dblib/@Generic__BookTextView/15108>
for details.

FreeTDS, which is used on *nix to connect to Sybase and MS SQL servers,
tries to imitate both modes:
- when compiled _without_ --enable-msdblib, gives dbdatecrack() which is
  Sybase-compatible,
- with --enable-msdblib - dbdatecrack() is compatible with MS SQL specs.

pymssql requires MS SQL mode, obviously, because we don't connect to Sybase.
FreeTDS headers are included in msdblib mode to get correct structure members.
But we can't reliably detect which mode FreeTDS was compiled in. Thus at
runtime it may turn out that dates are screwed.

If you can do nothing about FreeTDS, there's a workaround. You can redesign
your queries to return string instead of bare date:
  SELECT date FROM table
can be rewritten into:
  SELECT CONVERT(CHAR(10),date,120) AS date FROM table
This way SQL will send you string representing the date instead of binary date
in datetime or smalldatetime format, which has to be processed by FreeTDS
and pymssql.

On Windows there's no problem at all, because we link with MS library.