当前位置:网站首页>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();
边栏推荐
- Go 语言的 Context 详解
- Make web content editable
- Dynamic memory management
- Paper reading [MM21 pre training for video understanding challenge:video captioning with pre training techniqu]
- English grammar_ Noun possessive
- How Alibaba cloud's DPCA architecture works | popular science diagram
- In memory, I moved from CSDN to blog park!
- Preliminary practice of niuke.com (9)
- sql优化常用技巧及理解
- 毕业之后才知道的——知网查重原理以及降重举例
猜你喜欢
三级菜单数据实现,实现嵌套三级菜单数据
Photo selector collectionview
[论文阅读] A Multi-branch Hybrid Transformer Network for Corneal Endothelial Cell Segmentation
Dynamic memory management
判断文件是否为DICOM文件
SQL query: subtract the previous row from the next row and make corresponding calculations
The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
ForkJoin最全详解(从原理设计到使用图解)
Egr-20uscm ground fault relay
Reading the paper [sensor enlarged egocentric video captioning with dynamic modal attention]
随机推荐
What is message queuing?
ssm框架的简单案例
[paper reading] semi supervised left atrium segmentation with mutual consistency training
The year of the tiger is coming. Come and make a wish. I heard that the wish will come true
Differences and introduction of cluster, distributed and microservice
Mapbox Chinese map address
Digital innovation driven guide
Hcip seventh operation
论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】
AI人脸编辑让Lena微笑
TCC of distributed transaction solutions
Lombok plug-in
Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface
导航栏根据路由变换颜色
Photo selector collectionview
上海字节面试问题及薪资福利
K6el-100 leakage relay
消息队列:如何确保消息不会丢失
Preliminary practice of niuke.com (9)
基于NCF的多模块协同实例