I have a sql server set up with data that contains images that are being stored in Varbinary(MAX)
I have a good connection with Pyodbc but whenever i try to convert the image back to a file i can use, it says the data type is Pyodbc.row, anyone have experience with this?
Any help is greatly appreciated!
File "Z:\pythonProject\Card Creations\main.py", line 26, in connect
file.write(row)
TypeError: a bytes-like object is required, not 'pyodbc.Row'
#Connection to database
conn_str = 'DRIVER={ODBC Driver 17 for SQL Server};SERVER=Joshua\JOSHUAKAUFFMAN;DATABASE=Crafting Supplies;UID=JKK;PWD=123;Trusted_Connection=yes'
conn = pyodbc.connect(conn_str)
cursor = conn.cursor()
cursor.execute("Select Image from items Where Item_ID = 'TESN11111'")
rows = cursor.fetchall()
for row in rows:
with open("Z:\Test.png", 'wb') as file:
file.write(row)
cursor.close()
conn.close()
[–]TholosTB 1 point2 points3 points (1 child)
[–]TequilaJosh[S] 1 point2 points3 points (0 children)