I need to access spectroscopic data (x,y arrays) that are stored in a SQL Server 2008 database.
A while ago - with your help - I was able to get the data into a format I know how to work with.
Python 3 - decode spectroscopy data (Base64, IEEE754)
At the moment I use the SQLCMD
tool to access the database via:
p = Popen(["sqlcmd", "-S", host, "-U",...], stdin=PIPE, stdout=PIPE, stderr=PIPE)
output = p.stdout.read()
This is the only way I get the output I know how to deal with:
0xA79DFD6F14DCC23F242D1E1DFF50C43FAE9C624BD174...
Now I am not allowed to use the SQLCMD
tool anymore and need to get the data via pyodbc. I use pandas as well.
I try the following and it works well for all columns of the database but the important one.
I'm lost here - can you please advise how to proceed? The output looks like:
[(b'\xa7\x9d\xfdo\x14\xdc\xc2?$-\x1e\x1d\xffP\xc4?\xae\x9cbK\xd1t\xc4?\x8a\xfc}a
and the settings I use are as follows:
sql_conn = pyodbc.connect('DRIVER={ODBC Driver 13 for SQL Server};SERVER='+server+';DATABASE='+database+';UID='+username+';PWD='+ password)
query1 = '''SELECT TOP 1 [DATA] FROM [ABC].[dbo].[DATABASE]'''
df_q1 = pd.read_sql(query1, sql_conn)
I messed with encoding settings and failed.
EDIT:
array.array('d', df_q1.Data[0])
gives the expected numbers.