sfu-db / connector-x

Fastest library to load data from DB to DataFrames in Rust and Python
https://sfu-db.github.io/connector-x
MIT License
1.95k stars 154 forks source link

connectorx does not work in Google Colab #444

Open simon-paksam opened 1 year ago

simon-paksam commented 1 year ago

I cannot get connectorx to work on Colab. The following code sections execute fine locally in Jupyter Lab, but produce errors when run in Colab.

I thought this feedback might be helpful. Code examples are below.

==================================== USING CONNECTORX ON ITS OWN

!pip install connectorx

import connectorx as cx import pandas as pd

con = "mssql://username:password@server:1433/database"; query = "SELECT * FROM table_name" df = cx.read_sql(con, query) df

RuntimeError Traceback (most recent call last)

in 2 con = "mssql://username:password@server:1433/database" 3 query = "SELECT * FROM table_name" ----> 4 df = cx.read_sql(con, query) 5 df /usr/local/lib/python3.8/dist-packages/connectorx/__init__.py in read_sql(conn, query, return_type, protocol, partition_on, partition_range, partition_num, index_col) 222 raise ValueError("You need to install pandas first") 223 --> 224 result = _read_sql( 225 conn, 226 "pandas", RuntimeError: Timed out in bb8 ==================================== USING CONNECTORX WITH POLARS ==================================== !pip install connectorx !pip install polars import connectorx as cx import polars as pl con = "mssql://username:password@server:1433/database"; query = "SELECT * FROM table_name" df = pl.read_sql(query, con) df RuntimeError Traceback (most recent call last) in 3 con = "mssql://username:password@server:1433/database" 4 query = "SELECT * FROM table_name" ----> 5 df = pl.read_sql(query, con) 6 df 1 frames /usr/local/lib/python3.8/dist-packages/connectorx/__init__.py in read_sql(conn, query, return_type, protocol, partition_on, partition_range, partition_num, index_col) 255 raise ValueError("You need to install pyarrow first") 256 --> 257 result = _read_sql( 258 conn, 259 "arrow" if return_type in {"arrow", "polars"} else "arrow2", RuntimeError: Timed out in bb8 ===================================================
wangxiaoying commented 1 year ago

It seems like the error is due to the database connection timeout. Can you make sure you can access your database through colab?