电子说
Neon 是 AWS Aurora Postgres 的无服务器开源替代品。它将存储和计算分开,并通过跨节点集群重新分布数据来替代 PostgreSQL 存储层。 尝试使用 Neon 免费套餐创建无服务器 Postgres 实例。然后使用您首选的 Postgres 客户端(psql、dbeaver 等)连接到它或使用在线 SQL 编辑器。有关连接说明,请参阅从任何应用程序连接。或者,在本地编译并运行该项目。
Neon 由计算节点和 Neon 存储引擎组成。计算节点是由 Neon 存储引擎支持的无状态 PostgreSQL 节点。
Neon 存储引擎由两个主要组件组成: Pageserver - 计算节点的可扩展存储后端。 Safekeepers - Safekeepers 形成一个冗余的 WAL 服务,从计算节点接收 WAL,并将其持久存储,直到它被 Pageserver 处理并上传到云存储。
[dependencies] # `bundled` causes us to automatically compile and link in an up to date # version of SQLite for you. This avoids many common build issues, and # avoids depending on the version of SQLite on the users system (or your # system), which may be old or missing. It's the right choice for most # programs that control their own SQLite databases. # # That said, it's not ideal for all scenarios and in particular, generic # libraries built around `rusqlite` should probably not enable it, which # is why it is not a default feature -- it could become hard to disable. rusqlite = { version = "0.29.0", features = ["bundled"] }
use rusqlite::{Connection, Result}; #[derive(Debug)] struct Person { id: i32, name: String, data: Option<Vec<u8>>, } fn main() -> Result<()> { let conn = Connection::open_in_memory()?; conn.execute( "CREATE TABLE person ( id INTEGER PRIMARY KEY, name TEXT NOT NULL, data BLOB )", (), // empty list of parameters. )?; let me = Person { id: 0, name: "Steven".to_string(), data: None, }; conn.execute( "INSERT INTO person (name, data) VALUES (?1, ?2)", (&me.name, &me.data), )?; let mut stmt = conn.prepare("SELECT id, name, data FROM person")?; let person_iter = stmt.query_map([], |row| { Ok(Person { id: row.get(0)?, name: row.get(1)?, data: row.get(2)?, }) })?; for person in person_iter { println!("Found person {:?}", person.unwrap()); } Ok(()) }
全部0条评论
快来发表一下你的评论吧 !