SQLAlchemy connection string doesn't know DATABASE attribute

Connectivity
Connectivity covers the mechanisms for connecting to the Teradata Database, including driver connectivity via JDBC or ODBC.

SQLAlchemy connection string doesn't know DATABASE attribute

Hello!

 

I'm trying to create engine and connect to a specific Teradata database with SQLAlchemy and the teradatasql driver, but the standard attribute DATABASE is not known:

engine = create_engine('teradatasql://{UID}:{PWD}@{DBCNAME}/?DATABASE={DATABASE}'
.format(UID='myuid',
PWD='mypwd',
DBCNAME='mydbcname',
DATABASE='mydatabase'))

 

sqlalchemy.exc.OperationalError: (teradatasql.OperationalError) Unable to parse JSON connection parameters
at github.td.teradata.com/gosql/gosqldriver.git/teradatasql.parseConParams ConParams.go:48
at github.td.teradata.com/gosql/gosqldriver.git/teradatasql.(*teradataDriver).Open TeradataDriver.go:24
at database/sql.dsnConnector.Connect sql.go:600
at database/sql.(*DB).conn sql.go:1103
at database/sql.(*DB).Conn sql.go:1619
at main.goCreateConnection goside.go:93
at main._cgoexpwrap_9da3c3415413_goCreateConnection _cgo_gotypes.go:91
at runtime.call64 asm_amd64.s:574
at runtime.cgocallbackg1 cgocall.go:316
at runtime.cgocallbackg cgocall.go:194
at runtime.cgocallback_gofunc asm_amd64.s:826
at runtime.goexit asm_amd64.s:2361
Caused by json: unknown field "DATABASE" (Background on this error at: http://sqlalche.me/e/e3q8)

 

 

Please provide a way how to create engine with a specific schema.

Tags (1)
4 REPLIES
Teradata Employee

Re: SQLAlchemy connection string doesn't know DATABASE attribute

In SQLAlchemy create_engine, the schema (database) can be directly specified as part of the URL itself, so a parameter for DATABASE is not needed.

Try 'teradatasql://{UID}:{PWD}@{DBCNAME}/{DATABASE}'

Highlighted

Re: SQLAlchemy connection string doesn't know DATABASE attribute

Unfortunately this doesn't work also:

 

sqlalchemy.exc.OperationalError: (teradatasql.OperationalError) Unable to parse JSON connection parameters
 at github.td.teradata.com/gosql/gosqldriver.git/teradatasql.parseConParams ConParams.go:48
 at github.td.teradata.com/gosql/gosqldriver.git/teradatasql.(*teradataDriver).Open TeradataDriver.go:24
 at database/sql.dsnConnector.Connect sql.go:600
 at database/sql.(*DB).conn sql.go:1103
 at database/sql.(*DB).Conn sql.go:1619
 at main.goCreateConnection goside.go:93
 at main._cgoexpwrap_9da3c3415413_goCreateConnection _cgo_gotypes.go:91
 at runtime.call64 asm_amd64.s:574
 at runtime.cgocallbackg1 cgocall.go:316
 at runtime.cgocallbackg cgocall.go:194
 at runtime.cgocallback_gofunc asm_amd64.s:826
 at runtime.goexit asm_amd64.s:2361
Caused by json: unknown field "database" (Background on this error at: http://sqlalche.me/e/e3q8)

Teradata Employee

Re: SQLAlchemy connection string doesn't know DATABASE attribute

The Teradata SQL Driver for Python does not yet support the database connection parameter.

Teradata Employee

Re: SQLAlchemy connection string doesn't know DATABASE attribute

Thanks for the clarification @tomnolan. I must have been thinking about older PyTd/tdodbc with dialect teradata: instead of teradatasql.