SeaORM 连接 seekdb 示例程序
本文将介绍如何使用 SeaORM 和 seekdb 构建一个应用程序,实现创建表、插入数据和查询数据等基本操作。
环境准备
在开始之前,请确保已安装以下工具:
- Rust 1.60 或更高版本
- Cargo (Rust 的包管理器)
- 已安装 seekdb
创建新项目
cargo new sea-orm-seekdb-demo
cd sea-orm-seekdb-demo
添加依赖
编辑 Cargo.toml 文件,添加以下依赖:
[package]
name = "sea-orm-seekdb-demo"
version = "0.1.0"
edition = "2021"
[dependencies]
tokio = { version = "1.0", features = ["full"] }
sea-orm = { version = "0.12", features = [
"sqlx-mysql",
"runtime-tokio-rustls",
"macros",
"with-json"
] }
sea-orm-migration = "0.12"
serde = { version = "1.0", features = ["derive"] }
dotenv = "0.15"
async-std = { version = "1.12", features = ["attributes"] }
chrono = "0.4"