Clickhouse: PostgreSQL ODBC querying data failed

Created on 9 Oct 2018  Β·  1Comment  Β·  Source: ClickHouse/ClickHouse

Hello. Thanks for great DBMS. I have a problem: I'm trying to set up external dictionaries for PostgreSQL 10.1 on Debian 9 using Clickhouse 18.10.3.
But got an error during dictionary data querying with Sql command
SELECT dictGetString('accounts_pg_dict', 'login', toUInt64(1)) FROM system.one:

Poco Exception. Code: 1000, e.code() = 0, e.displayText() = Connection attempt failed: Connection:Not applicable
Server:gameserver-private
ODBC Diagnostic record 1
SQLSTATE = 08001
Native Error Code = 101
could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
, e.what() = Connection attempt failed

Here is my config files:
cat /etc/odbc.ini

[DEFAULT]
Driver = gameserver-private

[gameserver-private]
Description      = PostgreSQL connection to gameserver-private
Driver           = PostgreSQL Unicode
Servername       = 192.168.1.1
Database         = gameserver-private
UserName         = ***
Password         = ***
Port             = 5432
Protocol         = 10.1
ReadOnly         = No
RowVersioning    = No
ShowSystemTables = No
ConnSettings     =

cat /etc/odbcinst.ini

[PostgreSQL ANSI]
Description=PostgreSQL ODBC driver (ANSI version)
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbca.so
Setup=libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=1

[PostgreSQL Unicode]
Description=PostgreSQL ODBC driver (Unicode version)
Driver=/usr/lib/x86_64-linux-gnu/odbc/psqlodbcw.so
Setup=libodbcpsqlS.so
Debug=0
CommLog=1
UsageCount=1

cat /etc/clickhouse_substitutions.xml

<yandex>
    <gameserver_connection_string>DSN=gameserver-private;UID=***;PWD=***;HOST=192.168.1.1;PORT=5432;DATABASE=gameserver-private</gameserver_connection_string>
</yandex>

cat /etc/clickhouse-server/gameserver_dictionary.xml

<yandex>
    <include_from>/etc/clickhouse_substitutions.xml</include_from>
    <dictionary>
        <name>accounts_pg_dict</name>
        <source>
            <odbc>
                <connection_string incl="gameserver_connection_string"/>
                <table>accounts.accounts</table>
            </odbc>
        </source>
        <lifetime>
            <min>300</min>
            <max>450</max>
        </lifetime>
        <layout>
            <hashed/>
        </layout>
        <structure>
            <id>
                <name>id</name>
            </id>
            <attribute>
                <name>login</name>
                <type>String</type>
                <null_value>''</null_value>
            </attribute>
            <attribute>
                <name>is_developer</name>
                <type>UInt8</type>
                <null_value>0</null_value>
            </attribute>
            <attribute>
                <name>is_bot</name>
                <type>UInt8</type>
                <null_value>0</null_value>
            </attribute>
            <attribute>
                <name>created_at</name>
                <type>DateTime</type>
                <null_value>toDateTime('0000-00-00 00:00:00')</null_value>
            </attribute>
        </structure>
    </dictionary>
</yandex>

Also strange thing that I can query data via odbc with command from Clickhouse machine:
echo "select * from accounts.accounts LIMIT 10"| iusql gameserver-private -b

I have PostgreSQL and Clickhouse on different machines, why I get such an error? What am I doing wrong? :)

Most helpful comment

ΠŸΠΎΠΏΡ€Π°Π²ΠΈΠ»ΠΈ.
Ошибка Π±Ρ‹Π»Π° Π² Ρ‚ΠΎΠΌ, Ρ‡Ρ‚ΠΎ использовали "-" Π² Ρ„Π°ΠΉΠ»Π΅ odbc.ini, Π² Π½Π°Π·Π²Π°Π½ΠΈΠΈ: gameserver-private.
Π—Π°ΠΌΠ΅Π½ΠΈΠ»ΠΈ Π½Π° gameserverprivate ΠΈ всё Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Π»ΠΎ.
Ошибка ΠΊΠΎΡ‚ΠΎΡ€ΡƒΡŽ ΠΏΠΎΠ»ΡƒΡ‡Π°Π»ΠΈ Π² ΠΈΡ‚ΠΎΠ³Π΅ ΠΎΡ‡Π΅Π½ΡŒ Π·Π°ΠΏΡƒΡ‚Ρ‹Π²Π°Π»Π°, Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π°Π΄ΠΌΠΈΠ½ смог Π·Π°ΠΏΠΎΠ΄ΠΎΠ·Ρ€ΠΈΡ‚ΡŒ Π½Π΅Π»Π°Π΄Π½ΠΎΠ΅ Π² символС "-".

>All comments

ΠŸΠΎΠΏΡ€Π°Π²ΠΈΠ»ΠΈ.
Ошибка Π±Ρ‹Π»Π° Π² Ρ‚ΠΎΠΌ, Ρ‡Ρ‚ΠΎ использовали "-" Π² Ρ„Π°ΠΉΠ»Π΅ odbc.ini, Π² Π½Π°Π·Π²Π°Π½ΠΈΠΈ: gameserver-private.
Π—Π°ΠΌΠ΅Π½ΠΈΠ»ΠΈ Π½Π° gameserverprivate ΠΈ всё Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Π»ΠΎ.
Ошибка ΠΊΠΎΡ‚ΠΎΡ€ΡƒΡŽ ΠΏΠΎΠ»ΡƒΡ‡Π°Π»ΠΈ Π² ΠΈΡ‚ΠΎΠ³Π΅ ΠΎΡ‡Π΅Π½ΡŒ Π·Π°ΠΏΡƒΡ‚Ρ‹Π²Π°Π»Π°, Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Π°Π΄ΠΌΠΈΠ½ смог Π·Π°ΠΏΠΎΠ΄ΠΎΠ·Ρ€ΠΈΡ‚ΡŒ Π½Π΅Π»Π°Π΄Π½ΠΎΠ΅ Π² символС "-".

Was this page helpful?
0 / 5 - 0 ratings