当前位置:网站首页>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();
边栏推荐
- How can professional people find background music materials when doing we media video clips?
- Mybaits之多表查询(联合查询、嵌套查询)
- Educational Codeforces Round 22 B. The Golden Age
- JVM (XX) -- performance monitoring and tuning (I) -- Overview
- async / await
- Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
- Where is NPDP product manager certification sacred?
- 论文阅读【MM21 Pre-training for Video Understanding Challenge:Video Captioning with Pretraining Techniqu】
- Safe landing practice of software supply chain under salesforce containerized ISV scenario
- LabVIEW is opening a new reference, indicating that the memory is full
猜你喜欢

C#可空类型

Intelligent annotation scheme of entity recognition based on hugging Face Pre training model: generate doccano request JSON format

K6el-100 leakage relay

4. 对象映射 - Mapping.Mapster

DJ-ZBS2漏电继电器

Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
![[JS component] custom select](/img/9d/f7f15ec21763c40b9bb6a053d90ee4.jpg)
[JS component] custom select
![Paper reading [semantic tag enlarged xlnv model for video captioning]](/img/e3/633f6aac7a51ad7b3dc0e45dbe1f60.png)
Paper reading [semantic tag enlarged xlnv model for video captioning]

5. Data access - entityframework integration

架构设计的五个核心要素
随机推荐
4. 对象映射 - Mapping.Mapster
《2022中国低/无代码市场研究及选型评估报告》发布
DOM-节点对象+时间节点 综合案例
sql优化常用技巧及理解
拼多多新店如何获取免费流量,需要从哪些环节去优化,才能有效提升店内免费流量
什么是依赖注入(DI)
利用OPNET进行网络仿真时网络层协议(以QoS为例)的使用、配置及注意点
Dj-zbs2 leakage relay
TabLayout修改自定义的Tab标题不生效问题
“多模态”概念
High voltage leakage relay bld-20
《4》 Form
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
K6el-100 leakage relay
EGR-20USCM接地故障继电器
利用OPNET进行网络单播(一服务器多客户端)仿真的设计、配置及注意点
Initial experience of annotation
Paper reading [open book video captioning with retrieve copy generate network]
1.AVL树:左右旋-bite
Leakage relay llj-100fs