I have a Django project. I've connected a clickhouse table with a postgres table using clickhouse_fdw. Following clickhouse_fdw instructions, in postgres I did:
CREATE EXTENSION clickhousedb_fdw;
CREATE SERVER clickhouse_svr FOREIGN DATA WRAPPER clickhousedb_fdw OPTIONS(host 'host', dbname 'dbname', driver '/var/lib/postgresql/libclickhouseodbc.so');
CREATE USER MAPPING FOR CURRENT_USER SERVER clickhouse_svr;
CREATE FOREIGN TABLE clickhouse_table ("date_from" Date, "date_to" Date ... ) server clickhouse_svr options(table_name 'table');
This it's working using psql commands, but now I want to access from django (I can access all the others tables without any problems). I've added a new model for clickhouse table and ignored migrations and managment for it in django.
Then in django shell I've tried:
ClickHouseTable.objects.all()
ClickHouseTable.objects.raw('SELECT * FROM clickhouse_table LIMIT 1')[0]
from django.db import connection
with connection.cursor() as cursor:
cursor.execute('SELECT * FROM clickhouse_table LIMIT 1')
row = cursor.fetchone()
and with every query I get:
ProgrammingError: permission denied for foreign table clickhouse_table
Also from dbshell:
database => SELECT * FROM clickhouse_table LIMIT 1;
ERROR: permission denied for foreign table clickhouse_table
Any suggestions?