OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How to connect to Teradata Server using sqlalchemy and DSN less connection

  • Thread starter Thread starter Nrwparadise
  • Start date Start date
N

Nrwparadise

Guest
I can't figure out the right ODBC string I need to pass to the create engine statement.

This works​


Code:
import pyodbc
import pandas as pd

cnxn=pyodbc.connect('DRIVER=/opt/teradata/client/ODBC_64/lib/tdata.so;DBCName=Server;UID=UN;PWD=PW;Database=myDB')

query = "select top 10 * from TABLE"
df = pd.read_sql(query,cnxn)

This does not work​


Code:
import urllib
import sqlalchemy
params = urllib.parse.quote_plus('DRIVER=/opt/teradata/client/ODBC_64/lib/tdata.so;DBCName=Server;UID=UN;PWD=PW;Database=myDB')

engine = sqlalchemy.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)

query = "select top 10 * from TABLE"

df = pd.read_sql_query(query, engine)

I can get the pyodbc connection to work but not the sqlalchemy connection. Any help would be appreciated.

I get this error:

Code:
InterfaceError: (pyodbc.InterfaceError) ('IM001', '[IM001] [unixODBC][Driver Manager]Driver does not support this function (0) (SQLGetInfo)')
<p>I can't figure out the right ODBC string I need to pass to the create engine statement.</p>
<h1>This works</h1>
<pre class="lang-py prettyprint-override"><code>import pyodbc
import pandas as pd

cnxn=pyodbc.connect('DRIVER=/opt/teradata/client/ODBC_64/lib/tdata.so;DBCName=Server;UID=UN;PWD=PW;Database=myDB')

query = "select top 10 * from TABLE"
df = pd.read_sql(query,cnxn)
</code></pre>
<h1>This does not work</h1>
<pre class="lang-py prettyprint-override"><code>import urllib
import sqlalchemy
params = urllib.parse.quote_plus('DRIVER=/opt/teradata/client/ODBC_64/lib/tdata.so;DBCName=Server;UID=UN;PWD=PW;Database=myDB')

engine = sqlalchemy.create_engine("mssql+pyodbc:///?odbc_connect=%s" % params)

query = "select top 10 * from TABLE"

df = pd.read_sql_query(query, engine)
</code></pre>
<p>I can get the pyodbc connection to work but not the sqlalchemy connection. Any help would be appreciated.</p>
<p>I get this error:</p>
<pre><code>InterfaceError: (pyodbc.InterfaceError) ('IM001', '[IM001] [unixODBC][Driver Manager]Driver does not support this function (0) (SQLGetInfo)')
</code></pre>
 
Top