connector-x
connector-x copied to clipboard
connectorx does not work in Google Colab
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)
/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)
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
===================================================
It seems like the error is due to the database connection timeout. Can you make sure you can access your database through colab?