sqlalchemy-trino icon indicating copy to clipboard operation
sqlalchemy-trino copied to clipboard

support `df.to_sql(catalog=name ...)`

Open erikerlandson opened this issue 4 years ago • 2 comments

Currently the only way I know to tell sqlalchemy-trino about trino catalog name is in the connection url. That works pretty well but it would be conceptually cleaner to support df.to_sql(catalog=name, schema=name ...)

erikerlandson avatar Nov 25 '21 14:11 erikerlandson

Hello @erikerlandson It's pandas, right? Currently, df.to_sql has no catalog param, so there is no way to pass catalog to trino driver. If you find a way to do this, feel free to create a PR.

dungdm93 avatar Nov 26 '21 10:11 dungdm93

Studying code, the sanest approach I can think of that might work is to modify the biz-logic in the TrinoDialect methods to attempt a split of schema on . and split into catalog_name.schema_name, then add WHERE catalog = catalog_name clauses to various methods.

In such an approach, there would be no separate catalog =, but you would specify schema=catalog.schema.

The only other approach that came to mind was monkey-patching df.to_sql, but looking at how sqlalchemy is architected I suspect that adding a concept of "catalog" might have to be plumbed through a lot of layers of code, and would end up back in TrinoDialect anyway.

erikerlandson avatar Nov 26 '21 15:11 erikerlandson