<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sean{e}lavelle.com &#187; Linux</title>
	<atom:link href="http://www.seanelavelle.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.seanelavelle.com</link>
	<description>Coding, Photography, Travel and whatever else is exciting to me these days</description>
	<lastBuildDate>Sun, 08 Jan 2012 14:14:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PyODBC and FreeTDS : Unicode ntext problem [Solved]</title>
		<link>http://www.seanelavelle.com/2011/07/30/pyodbc-and-freetds-unicode-ntext-problem-solved/</link>
		<comments>http://www.seanelavelle.com/2011/07/30/pyodbc-and-freetds-unicode-ntext-problem-solved/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 21:24:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.seanelavelle.com/?p=18</guid>
		<description><![CDATA[While working on a script to find blocking processes on a SQL Server 2008 database, I ran across this error when I tried to execute a query: $ python find_blocking_processes.py Traceback (most recent call last): File "find_blocking_processes.py", line 77, in &#8230; <a href="http://www.seanelavelle.com/2011/07/30/pyodbc-and-freetds-unicode-ntext-problem-solved/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>While working on a script to find blocking processes on a SQL Server 2008 database, I ran across this error when I tried to execute a query:</p>
<pre>$ python find_blocking_processes.py
Traceback (most recent call last):
File "find_blocking_processes.py", line 77, in &lt;module&gt;
find_blocking_processes(brokerConn)
File "find_blocking_processes.py", line 67, in find_blocking_processes
) x""").fetchall()
pyodbc.ProgrammingError: ('42000', '[42000] [FreeTDS][SQL Server]Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier. (4004) (SQLExecDirectW)')</pre>
<p>After a bit of digging, it appears that you need to tell the ODBC driver which protocol to talk to a server in. Rectifying this was pretty straight forward:</p>
<p>In the file /etc/freetds.conf I added a line to the serverconfig  stating to use the version 8.0 protocol:</p>
<pre># A typical Microsoft SQL Server 2008 configuration
[DEVDATABASE]
host = 10.10.10.100
port = 1433
tds version = 8.0</pre>
<p>Then in the file /etc/odbc.ini I added a line for the version as well:</p>
<pre>[DEVDATABASE]
Driver          = /usr/lib64/libtdsodbc.so.0
Server          = 10.10.10.100
Port            = 1433
Trace           = Yes
TraceFile       = /tmp/freetdssql-foobar.log
tds_version     = 8.0</pre>
<p>* Note the &#8216;_&#8217; in the tds_version  variable in the odbc.ini</p>
<p>After this, the database call ran like a dream.</p>
<p>These were the links that pointed me in the right direction to solve this issue and contain a little more information on the causes of this:</p>
<ul>
<li>FreeTDS Error while trying to retrieve information from an ntext field &#8211; <a href="http://www.ubuntitis.com/?p=64">http://www.ubuntitis.com/?p=64</a></li>
<li>PyODBC, UnixODBC, FreeTDS – config &#8211; <a href="http://kipb7.wordpress.com/2008/06/12/pyodbc-unixodbc-freetds-config/">http://kipb7.wordpress.com/2008/06/12/pyodbc-unixodbc-freetds-config/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.seanelavelle.com/2011/07/30/pyodbc-and-freetds-unicode-ntext-problem-solved/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

