当前位置:网站首页>Flinksql 读写pgsql
Flinksql 读写pgsql
2022-07-06 23:51:00 【zs_bigdata】
一. 代码
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/数据库',\n" +
" 'username' = 'xx', " +
" 'password' = 'xxxx', " +
" 'table-name' = 'schema名.表名'\n" +
")"
);
2 踩坑
如果pgsql使用了schema,name此时表名需要``转义,否则会报找不到medical object
// `medical.hospital_department` 一定要转义
tableEnv.executeSql("select id,name from `medical.hospital_department`").print();
边栏推荐
- [binary tree] binary tree path finding
- 基于NCF的多模块协同实例
- Dj-zbs2 leakage relay
- Getting started with DES encryption
- JVM (19) -- bytecode and class loading (4) -- talk about class loader again
- 《2022中国低/无代码市场研究及选型评估报告》发布
- DOM node object + time node comprehensive case
- 京东商品详情页API接口、京东商品销量API接口、京东商品列表API接口、京东APP详情API接口、京东详情API接口,京东SKU信息接口
- WEB架构设计过程
- Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
猜你喜欢
![[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training](/img/d6/e6db0d76e81e49a83a30f8c1832f09.png)
[论文阅读] Semi-supervised Left Atrium Segmentation with Mutual Consistency Training

Flink SQL 实现读写redis,并动态生成Hset key

Leakage relay llj-100fs

常用消息队列有哪些?

Common skills and understanding of SQL optimization

JVM(二十) -- 性能监控与调优(一) -- 概述

Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface

How does mapbox switch markup languages?

架构设计的五个核心要素

Unity让摄像机一直跟随在玩家后上方
随机推荐
分布式事务介绍
np. random. Shuffle and np Use swapaxis or transfer with caution
Phenomenon analysis when Autowired annotation is used for list
5阶多项式轨迹
不同网段之间实现GDB远程调试功能
Sorry, I've learned a lesson
论文阅读【Open-book Video Captioning with Retrieve-Copy-Generate Network】
Design, configuration and points for attention of network unicast (one server, multiple clients) simulation using OPNET
App clear data source code tracking
Intelligent annotation scheme of entity recognition based on hugging Face Pre training model: generate doccano request JSON format
纪念下,我从CSDN搬家到博客园啦!
[JS component] date display.
Dj-zbs2 leakage relay
Paper reading [open book video captioning with retrieve copy generate network]
Common skills and understanding of SQL optimization
Talk about mvcc multi version concurrency controller?
Batch size setting skills
Where is NPDP product manager certification sacred?
English语法_名词 - 所有格
论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】