use klickhouse::*;
mod embedded {
use refinery::embed_migrations;
// 指定sql文件路径
embed_migrations!("./src/sql_migrations/");
}
#[tokio::main]
async fn main() -> Result<()> {
// 建立与 Klickhouse 的连接
let mut client = Client::connect("172.xx.xxx.xx:9000", ClientOptions{
default_database: "default".to_string(),
username: "default".to_string(),
password: String::new(),
}).await?;
// 运行嵌入的数据库迁移
embedded::migrations::runner().run_async(&mut client).await.unwrap();
Ok(())
}
[dependencies]
chrono = "0.4.34"
futures = "0.3.30"
# klickhouse = "0.11.0"
klickhouse = { version = "0.12.0", features = ["refinery"] }
rand = "0.8.4"
tokio = { version = "1.26.0", default-features = false, features = ["full"] }
uuid = "1.7.0"
refinery = { version = "0.8"}
rusqlite = "0.31.0"
每个库都会生成一张refinery_schema_history元数据表,所以建议各个业务方以自己project名建库名,示例如下
Project:bigdata
database:bigdata
元数据表:bigdata.refinery_schema_history
元数据表所在节点:172.xx.xxx.xx
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有