当前位置:网站首页>Flinksql read / write PgSQL
Flinksql read / write PgSQL
2022-07-07 05:44:00 【zs_ bigdata】
One . Code
StreamTableEnvironment tableEnv = StreamTableEnvironment.create(env, EnvironmentSettings.inStreamingMode());
AbstractJdbcCatalog catalog = JdbcCatalogUtils.createCatalog(
"myPgsql",
"staging",
"username",
"password",
"jdbc:postgresql://xxx:port"
);
tableEnv.registerCatalog("myPgsql", catalog);
tableEnv.useCatalog("myPgsql");
tableEnv.useDatabase("staging");
boolean staging = catalog.tableExists(new ObjectPath("staging", "medical.hospital_department"));
System.out.println(staging);
System.out.println(Arrays.toString(tableEnv.listCatalogs()));
System.out.println(Arrays.toString(tableEnv.listDatabases()));
//System.out.println(Arrays.toString(tableEnv.listTables()));
tableEnv.executeSql("select id,name from `medical.hospital_department`").print();
//sql api
tableEnv.executeSql(
"CREATE TABLE hospital_position (\n" +
" id string,\n" +
" department_id string,\n" +
" waypoint_id STRING,\n" +
" zone_id STRING,\n" +
" PRIMARY KEY (id) NOT ENFORCED\n" +
") WITH (\n" +
" 'connector' = 'jdbc',\n" +
" 'url' = 'jdbc:postgresql://xxxxx:port/ database ',\n" +
" 'username' = 'xx', " +
" 'password' = 'xxxx', " +
" 'table-name' = 'schema name . Table name '\n" +
")"
);
2 Step on the pit
If pgsql Used schema,name At this time, the table name needs `` escape , Otherwise, we will not find medical object
// `medical.hospital_department` Must escape
tableEnv.executeSql("select id,name from `medical.hospital_department`").print();
边栏推荐
猜你喜欢

JD commodity details page API interface, JD commodity sales API interface, JD commodity list API interface, JD app details API interface, JD details API interface, JD SKU information interface

什么是依赖注入(DI)

Cve-2021-3156 vulnerability recurrence notes

C nullable type

Zero sequence aperture of leakage relay jolx-gs62 Φ one hundred

The navigation bar changes colors according to the route

bat 批示处理详解

爬虫练习题(三)

常用消息队列有哪些?

1. AVL tree: left-right rotation -bite
随机推荐
Educational Codeforces Round 22 B. The Golden Age
async / await
《2022中国低/无代码市场研究及选型评估报告》发布
Dj-zbs2 leakage relay
Preliminary practice of niuke.com (9)
【日常训练--腾讯精选50】292. Nim 游戏
论文阅读【Open-book Video Captioning with Retrieve-Copy-Generate Network】
得物客服一站式工作台卡顿优化之路
爬虫练习题(三)
架构设计的五个核心要素
Jhok-zbg2 leakage relay
1. AVL tree: left-right rotation -bite
I didn't know it until I graduated -- the principle of HowNet duplication check and examples of weight reduction
《ClickHouse原理解析与应用实践》读书笔记(6)
Zero sequence aperture of leakage relay jolx-gs62 Φ one hundred
K6el-100 leakage relay
消息队列:消息积压如何处理?
Aidl and service
JVM (19) -- bytecode and class loading (4) -- talk about class loader again
5. Data access - entityframework integration