flink1.14 sql通过JdbcCatalog连接postgresql踩坑记录
from pyflink.datastream import StreamExecutionEnvironment
from pyflink.table import StreamTableEnvironment, EnvironmentSettings
from pyflink.table.catalog import JdbcCatalog
from pyflink.table.types import Row
env = StreamExecutionEnvironment.get_execution_environment()
env_settings = EnvironmentSettings.new_instance().in_streaming_mode().use_blink_planner().build()
t_env = StreamTableEnvironment.create(env, environment_settings=env_settings)
t_env.get_config().get_configuration().set_string("taskmanager.memory.task.off-heap.size", '100m')
JdbcCatalog 已装依赖包
flink sql通过JdbcCatalog连接postgresql数据库,从而实现直接对postgresql表的相关操作,相关代码如下:
sc_catalog_name = "mycatalog"
sc_default_database = "postgres"
sc_username = "root"
sc_password = "123456"
sc_base_url = "jdbc:postgresql://xxxx.xx.xxx.xxx:3306"
sc_catalog = JdbcCatalog(sc_catalog_name, sc_default_database, sc_username