Unable to retrieve column list for table with Russian symbols

95 views Asked by At

With SQLAlchemy retrieving the column list for a table with an English table name works:

table = Table('073_mappings', metadata, autoload=True, schema=schema_name)
connection = engine.connect()
columns = table.columns.keys()
print(columns)

When I use a table name with Russian characters:

table = Table('073_Мэппинги', metadata, autoload=True, schema=schema_name)

It returns an empty list. The table with the Russian name does exist in database and I can work with it directly in Exasol. I tried setting various encodings in the connection string: 'utf8', 'utf8mb4' and 'cp1251'. Database supports Russian characters because I can work with it directly in Exasol. This kind of query using SQLAlchemy works too:

sql_statement = text(
        """
        SELECT COLUMN_NAME
        FROM EXA_ALL_COLUMNS
        WHERE COLUMN_SCHEMA = :schema_name
        AND COLUMN_TABLE = :table_name
        """
    )
result = connection.execute(
        sql_statement, schema_name=schema_name, table_name=table_name).fetchall()

How to retrieve the column list for a table with a Russian name in Exasol? Is there a specific encoding or configuration I need to set? Some additional information. I connect to exasol DB using pyodbc, my connection string looks like this:

engine = create_engine("exa+pyodbc://EXADB")

I use ODBC driver. I create table by the query like this (just an example):

CREATE TABLE "AMS_TMP"."Таблица_1" (
    "Первая_12" VARCHAR(12),
    "Вторая_12" VARCHAR(12),
    "Третья_12" VARCHAR(12),
    "Четвертая_12" VARCHAR(12)
);
1

There are 1 answers

0
Alexander Lipatiev On

Seems to work for me with ODBC driver version 7.1.22.

from sqlalchemy import create_engine, Table, MetaData
url = "exa+pyodbc://sys:exasol@exasolution-uo2214lv2_64/test?CONNECTIONLCALL=en_US.UTF-8"
e = create_engine(url)
metadata_obj = MetaData(bind=None)
tab_name = 'some non-ASCII stuff'
table = Table(tab_name, metadata_obj, autoload_with=e, schema='test')
columns = table.columns.keys()
print(columns)