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
2.02k stars 162 forks source link

mssql uniqueidentifiers downloaded in lower case #151

Closed bloukanov closed 3 years ago

bloukanov commented 3 years ago

Hi,

I find that uniqueidentifier fields are being downloaded in lower case from MS SQL - do you see the same issue?

wangxiaoying commented 3 years ago

Hi @bloukanov ,

Seems like mssql stores uniqeidentifier in 16-byte GUID, which is a number and will be represented as a string of hexadecimal digit. I tried using both mssql-cli client and pymssql driver, they all show the lowercase result. image

If you want to get an uppercase result, one way is to convert the type into a string, for example:

select CONVERT(VARCHAR(50), test_uuid) as test_uuid from table

It will return the uppercase result

bloukanov commented 3 years ago

thanks @wangxiaoying it is actually easy enough for me to do df.id.str.upper() after the download. just wanted to bring it up! pd.read_sql downloads it in upper case

wangxiaoying commented 3 years ago

thanks @wangxiaoying it is actually easy enough for me to do df.id.str.upper() after the download. just wanted to bring it up! pd.read_sql downloads it in upper case

I think it depends on the underlying driver. In my case through pd.read_sql, using pymssql engine (https://docs.sqlalchemy.org/en/14/core/engines.html#microsoft-sql-server) the result is in lower case.

Actually we do not produce this string by ourselves but only get the value from the underlying Rust driver (https://docs.rs/tiberius/0.6.5/tiberius/). Seems like there is no regulation on this case (C# in lowercase and JDBC in uppercase), so I will close this issue for now. But thanks for bringing it up anyway!

bloukanov commented 3 years ago

@wangxiaoying ah I see, got it!