I am trying to read SQL Server data to polars DataFrame in Rust with connectorx. However, I never succeeded with windows authentication. When run, it returns
Query failed: SourceNotSupport("MsSQL")
The code is below.
// main.rs
use polars::prelude::*;
use connector::prelude::*;
fn main(){
let bs_df: DataFrame = create_df_connectorx();
println!("{:?}", bs_df);
}
fn create_df_connectorx() {
let connection_str: &str = "mssql://sample_servername/sample_databasename?integratedSecurity=true";
let source_conn: SourceConn = SourceConn::try_from(connection_str).expect(msg:"failed to create connection");
let queries: &[CXQuery;1] = &[CXQuery::from("select * from sample_tablename")];
//error occurs on this line
let destination: Arrow2Destination=connectorx::get_arrow2::get_arrow2(
&source_conn,
None,
queries).expect(msg: "Query failed");
let df: DataFrame = rlt.polars().unwrap();
df
}
//Cargo.toml
[package]
name="query_sqlserver"
version="0.1.0"
edition="2021"
[dependencies]
connectorx={version="^0.3.3", features=["dst_arrow2"]}
polars={version="0.32"}
Did not get a chance to try the connection with account name and password for the default way to login to the company database is windows authentication.
Maybe I missed something important, I searched this topic but did not find an example that connectorx reads data from mssql with windows authentication. And not even sure if connectorx support mssql windows authentication now (there are examples to query with account name and password).
read_databasecall?connectorx::get_arrow2isn't a Polars method. Have you tried using connectorx'sread_sqlmethod instead ofget_arrow2? connectorx supports SQL Server but this particular method may notintegratedSecurity? Have you triedtrusted_connection=trueas per the connector-x docs?trusted_connection=truewhich does not make a difference. What surprised me is, I tried the same code on my personal laptop with a PostGreSQL database (connection string updated accordingly), last night I got aSourceNotSupport("Postgre")error.