当前位置:网站首页>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();
边栏推荐
- Reading the paper [sensor enlarged egocentric video captioning with dynamic modal attention]
- Flink SQL realizes reading and writing redis and dynamically generates hset key
- High voltage leakage relay bld-20
- 2pc of distributed transaction solution
- sql优化常用技巧及理解
- 纪念下,我从CSDN搬家到博客园啦!
- TCC of distributed transaction solutions
- Educational Codeforces Round 22 B. The Golden Age
- Getting started with DES encryption
- 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
猜你喜欢

Photo selector collectionview

The navigation bar changes colors according to the route

CVE-2021-3156 漏洞复现笔记

论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】

得物客服一站式工作台卡顿优化之路

JVM (19) -- bytecode and class loading (4) -- talk about class loader again

Introduction to distributed transactions

什么是消息队列?

爬虫练习题(三)

I didn't know it until I graduated -- the principle of HowNet duplication check and examples of weight reduction
随机推荐
Mybaits multi table query (joint query, nested query)
C#可空类型
分布式事务解决方案之TCC
[paper reading] semi supervised left atrium segmentation with mutual consistency training
得物客服一站式工作台卡顿优化之路
C nullable type
【已解决】记一次EasyExcel的报错【读取xls文件时全表读不报错,指定sheet名读取报错】
Make web content editable
拼多多新店如何获取免费流量,需要从哪些环节去优化,才能有效提升店内免费流量
Cve-2021-3156 vulnerability recurrence notes
4. 对象映射 - Mapping.Mapster
Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
关于服装ERP,你知道多少?
Simple case of SSM framework
Sidecar mode
Reading the paper [sensor enlarged egocentric video captioning with dynamic modal attention]
JVM the truth you need to know
nVisual网络可视化
软件测试面试技巧
Initial experience of annotation