Running multiple commands using trino python client - trino dbapi

Viewed 27

How can I run multiple statments in trino python client? https://github.com/trinodb/trino-python-client Below is the sample code.

queries = filter(None, query.split(";"))
        for singelQuery in queries:
            cursor.execute(singelQuery)
            rows = cursor.fetchall()

Query

use test; select * from tbl

Getting below error

TrinoUserError(type=USER_ERROR, name=MISSING_SCHEMA_NAME, message="line 1:16: Schema must be specified when session schema is not set", query_id=20220908_082529_00009_uw5yi)
1 Answers

for that specific error message you have to mention your catalog name and schema name :

use catalog.test;

If a catalog is not specified, the schema is resolved relative to the current catalog.

alternatively you can run your query like this , instead of using use :

select * from catalog_name.test.tbl;

for running multiple statements per query , you probably need to use trino cli , not sure iff python client support that,

>> trino client --file $filename
Related