rust postgres

python;gutter:true; use postgres::{Client, NoTls};</p> <p>fn main(){ let mut client = Client::connect("host=localhost user=postgres password=postgres port=5433", NoTls).unwrap();</p> <pre><code>client.batch_execute(" CREATE TABLE person ( id SERIAL PRIMARY KEY, name TEXT NOT NULL, data BYTEA ) ").unwrap(); let name = "Ferris"; let data = None::; client.execute( "INSERT INTO person (name, data) VALUES ($1, $2)", &[&name, &data], ).unwrap(); for row in client.query("SELECT id, name, data FROM person", &[]).unwrap() { let id: i32 = row.get(0); let name: &str = row.get(1); let data: Option = row.get(2); println!("found person: {} {} {:?}", id, name, data); } </code></pre> <p>}

Original: https://www.cnblogs.com/pythonClub/p/16524570.html
Author: CrossPython
Title: rust postgres

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/15784/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总