当前位置:网站首页>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();
边栏推荐
- Differences and introduction of cluster, distributed and microservice
- Unity keeps the camera behind and above the player
- Mybaits之多表查询(联合查询、嵌套查询)
- Go 語言的 Context 詳解
- Initial experience of annotation
- 拼多多新店如何获取免费流量,需要从哪些环节去优化,才能有效提升店内免费流量
- 5. Data access - entityframework integration
- SAP ABAP BDC(批量数据通信)-018
- 4. Object mapping Mapster
- Modes of optical fiber - single mode and multimode
猜你喜欢
Common skills and understanding of SQL optimization
Message queuing: how to ensure that messages are not lost
High voltage leakage relay bld-20
Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface
论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
Egr-20uscm ground fault relay
毕业之后才知道的——知网查重原理以及降重举例
什么是消息队列?
Cve-2021-3156 vulnerability recurrence notes
Leakage relay jd1-100
随机推荐
Hcip eighth operation
The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
Educational Codeforces Round 22 B. The Golden Age
Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
Flinksql 读写pgsql
论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】
pytorch_ 01 automatic derivation mechanism
Nodejs get client IP
Pytorch builds neural network to predict temperature
淘宝商品详情页API接口、淘宝商品列表API接口,淘宝商品销量API接口,淘宝APP详情API接口,淘宝详情API接口
Flink SQL 实现读写redis,并动态生成Hset key
What is dependency injection (DI)
An example of multi module collaboration based on NCF
Simple case of SSM framework
SQLSTATE[HY000][1130] Host ‘host. docker. internal‘ is not allowed to connect to this MySQL server
Sidecar mode
【Shell】清理nohup.out文件
消息队列:消息积压如何处理?
导航栏根据路由变换颜色
JVM (XX) -- performance monitoring and tuning (I) -- Overview