connector-x icon indicating copy to clipboard operation
connector-x copied to clipboard

connectorx does not work in Google Colab

Open simon-paksam opened this issue 2 years ago • 1 comments

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

===================================================

simon-paksam avatar Feb 04 '23 18:02 simon-paksam

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

wangxiaoying avatar Feb 10 '23 02:02 wangxiaoying