sqlalchemy-teradata connection from python

Connectivity
Teradata Employee

Re: sqlalchemy-teradata connection from python

conn_img and td_engine are not the same. conn_img is using pyodbc to connect to the database using odbc, however creating an engine with teradata dialect creates a connection to the database using using another dbapi driver called tdodbc.

 

The engine you use in the to_sql method is a connection to the sqlite database, not teradata. Is that what you are trying to do? What database is in your DSN (LMG-LDAP) when you connect with pyodbc?

Teradata Employee

Re: sqlalchemy-teradata connection from python

How is conn_bmg defined? It may have to do with the odbc driver you are using, make sure you are using the teradata-odbc driver.

See: 

- https://github.com/Teradata/sqlalchemy-teradata/wiki/Installation

http://developer.teradata.com/tools/articles/teradata-sqlalchemy-introduction#Getting-Started

Enthusiast

Re: sqlalchemy-teradata connection from python

I installed anaconda and using jypter as shell.

I came to know that  once we install anaconda automatically all packages will get installed .

 

Teradata Employee

Re: sqlalchemy-teradata connection from python

Are you familiar with the python and jupyter environment? Are you using virtual enviornments?

You can check what packages you have installed with `conda list`. Can you ensure that it has sqlalchemy-teradata?

 

Enthusiast

Re: sqlalchemy-teradata connection from python

Yes my DSN is LOG_LDAP

Enthusiast

Re: sqlalchemy-teradata connection from python

I am new to this eniv.. Learning..

Did some data prasing in python and want to send back that data into teradata tables.

Yes i did i am able to see sqlalchemy V 1.2..11

And I cant see 'sqlalchemy - teradata'

 

Enthusiast

Re: sqlalchemy-teradata connection from python

here my connections:

 

td_userID = getpass.getpass('Enter User id')
td_password = getpass.getpass('Enter pwd')
conn_lmg = pyodbc.connect('DSN=xxxx;UID='+str(td_userID)+';PWD='+str(td_password))
del td_password, td_userID
conn_lmg
conn_lmg.autocommit = True
curs = conn_lmg.cursor()

Enthusiast

Re: sqlalchemy-teradata connection from python

getting this issue while iam installing

 

pip install sqlalchemy-teradata

Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1045)'))': /simple/sqlalchemy-teradata/

Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1045)'))) - skipping

Highlighted
Teradata Employee

Re: sqlalchemy-teradata connection from python

Looks like an outdated pip. I would suggest upgrading pip: https://github.com/pypa/pip/issues/5226

Enthusiast

Re: sqlalchemy-teradata connection from python

I requested my admin to install that packages in my local machine.

 

Mean while i am exporting dataframe data into csv and and insertting that data into table in python.. i am getting this error. Please can you help me in this..

df1.to_csvpath ,index=False) -- data imported to csv

 

import csv
with open(path)as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        #print(row['STMT_DESC'],row['Sum(tran_amt)'], row['Sum(tran_cnt)'])
        curs.execute(""""INSERT INTO PYTHON_LKP(STMT_DESC,tran_amt, tran_cnt )VALUES(?,?,?)""",(row))

 

error message :

 

ProgrammingError: ('42000', '[42000] [Teradata][ODBC Teradata Driver][Teradata Database] String not terminated before end of text.  (-3760) (SQLPrepare)')