Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ProgrammingError" ('Type mismatch between TVP row values', 'HY000') #659

Closed
Lijo-CheeranJoseph opened this issue Dec 15, 2019 · 3 comments

Comments

@Lijo-CheeranJoseph
Copy link

I have following working code that successfully inserted 10K records into SQL Server using Table Valued Parameter (TVP). When I run the code with 400K records, I got error ""ProgrammingError" ('Type mismatch between TVP row values', 'HY000')". How to resolve this?

import pyodbc
from datetime import datetime

def main():

now_MainStart = datetime.now()
print(now_MainStart)

f = open('C:/Source/test_public.pem', 'rb')
f1 = open('C:/Source/test_private.pem', 'rb')
public = RSA.importKey(f.read())
private = RSA.importKey(f1.read())

cnxn = pyodbc.connect("Driver={ODBC Driver 13 for SQL Server};Server=dataserver;UID=UserName;PWD=Passwrd;Database=MySQLServerDB;")
dfInput = pd.read_sql('exec dbo.usp_Temp_GetAllUsers ?', cnxn, params=['None'] )

df_Store = pd.DataFrame(columns=['PatientText', 'EncryptedResult'])

for index, row in dfInput.iterrows():
y = row['PatientText']
message = base64.b64encode(y.encode("utf-8"))
dataNew = base64.b64decode(message)

encoded = my_encrypt(dataNew, public)
decryptedResult = decrypt_New(encoded, private)

df_Store = df_Store.append({'PatientText': y, 'EncryptedResult': encoded}, ignore_index=True)

now_EncryptionDone = datetime.now()
print(now_EncryptionDone)

try:
cursor = cnxn.cursor()
result_array = cursor.execute("EXEC dbo.usp_InsertUsers ?", [df_Store.values]).fetchall()
cursor.commit() #very important to commit
#print(result_array)

now_UpdateDone = datetime.now()
print(now_UpdateDone)

except Exception as ex:
print("Failed to execute SP with TVPt")
print("Exception: [" + type(ex).name + "]", ex.args)

if name== "main":
main()

@gordthompson
Copy link
Collaborator

Possibly related: #596

@mkleehammer
Copy link
Owner

Now that #596 is closed, is this still happening @Lijo-CheeranJoseph ?

@keitherskine
Copy link
Collaborator

Closed due to inactivity. Feel free to re-open with current information if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants