首页 > 其他分享 >arrow obdc

arrow obdc

时间:2022-09-30 16:44:56浏览次数:34  
标签:unwrap odbc batch cursor let arrow obdc

use arrow_odbc::{odbc_api::Environment, OdbcReader};

const CONNECTION_STRING: &str = "Driver={PostgreSQL ANSI(x64)}; Server=127.0.0.1;Port=5433; UID=postgres; PWD=postgres;";

fn main() {

    let odbc_environment = Environment::new().unwrap();
    
    // Connect with database.
    let connection = odbc_environment.connect_with_connection_string(CONNECTION_STRING).unwrap();

    // This SQL statement does not require any arguments.
    let parameters = ();

    // Execute query and create result set
    let cursor = connection
        .execute("SELECT * FROM hzfc limit 3", parameters).unwrap()
        .expect("SELECT statement must produce a cursor");

    // Each batch shall only consist of maximum 10.000 rows.
    let max_batch_size = 10_000;

    // Read result set as arrow batches. Infer Arrow types automatically using the meta
    // information of `cursor`.
    let arrow_record_batches = OdbcReader::new(cursor, max_batch_size).unwrap();

    for batch in arrow_record_batches {
        println!("{:?}", batch.unwrap());
        println!("===============================\n");
    }
    // Ok(())
}

  

标签:unwrap,odbc,batch,cursor,let,arrow,obdc
From: https://www.cnblogs.com/pythonClub/p/16745366.html

相关文章

  • Python第三方库arrow
    Python第三方库arrowhttps://pypi.org/project/arrow/简介处理时间日期的一个第三方库ArrowisaPythonlibrarythatoffersasensibleandhuman-friendly......
  • 「CF1661E」 Narrow Components
    \(\texttt{「CF1661E」NarrowComponents}\)\(\texttt{Describe}\)给你一个\(3\)行\(n\)列的\(01\)矩阵\(a\),其中\(0\)表示黑色格子,\(1\)表示白色格子。再给......