当前位置:网站首页>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();
边栏推荐
- Mapbox Chinese map address
- 论文阅读【Sensor-Augmented Egocentric-Video Captioning with Dynamic Modal Attention】
- Most commonly used high number formula
- JVM(二十) -- 性能监控与调优(一) -- 概述
- Flink SQL 实现读写redis,并动态生成Hset key
- 漏电继电器JD1-100
- Vector and class copy constructors
- Paper reading [MM21 pre training for video understanding challenge:video captioning with pre training techniqu]
- 利用OPNET进行网络仿真时网络层协议(以QoS为例)的使用、配置及注意点
- Flink SQL realizes reading and writing redis and dynamically generates hset key
猜你喜欢
【js组件】date日期显示。
Preliminary practice of niuke.com (9)
Paper reading [open book video captioning with retrieve copy generate network]
Digital innovation driven guide
Zero sequence aperture of leakage relay jolx-gs62 Φ one hundred
张平安:加快云上数字创新,共建产业智慧生态
Senior programmers must know and master. This article explains in detail the principle of MySQL master-slave synchronization, and recommends collecting
Under the trend of Micah, orebo and apple homekit, how does zhiting stand out?
JVM(十九) -- 字节码与类的加载(四) -- 再谈类的加载器
Mysql database learning (8) -- MySQL content supplement
随机推荐
Lombok插件
Mysql database learning (8) -- MySQL content supplement
Flink SQL 实现读写redis,并动态生成Hset key
Jhok-zbg2 leakage relay
Paper reading [MM21 pre training for video understanding challenge:video captioning with pre training techniqu]
张平安:加快云上数字创新,共建产业智慧生态
Taobao commodity details page API interface, Taobao commodity list API interface, Taobao commodity sales API interface, Taobao app details API interface, Taobao details API interface
Jhok-zbl1 leakage relay
Record a pressure measurement experience summary
Educational Codeforces Round 22 B. The Golden Age
High voltage leakage relay bld-20
Pytest testing framework -- data driven
Zhang Ping'an: accelerate cloud digital innovation and jointly build an industrial smart ecosystem
Pinduoduo product details interface, pinduoduo product basic information, pinduoduo product attribute interface
Design, configuration and points for attention of network unicast (one server, multiple clients) simulation using OPNET
【js组件】自定义select
Getting started with DES encryption
Make web content editable
[JS component] custom select
《4》 Form