1

I've a simple function

def DatabaseDoQuery(sql, records = pandas.DataFrame()):
    conn = ceODBC.connect("DRIVER={SQL Server};SERVER=temp;Trusted_connection=yes")    
    cursor = conn.cursor()  
    if ('insert' in sql.lower()) and (~records.empty):
        tuples =  [tuple(x) for x in records.values]       
        cursor.executemany(sql,tuples)
        conn.commit()
    else: 
        cursor.execute(sql)
        conn.commit()
    conn.close()

when i call this function first to delete the records in a table and then to insert records into the same table, i get this message:

DatabaseError: cannot get diagnostic message.

Could you please help?

2 Answers 2

0

As AlxM stated, this error occurs when the diagnostic message is too large. This is sometimes due to a primary key violation on a large number of records, but it can also be a caused by a data conversion error. Try your operation with smaller chunks of data, and you'll be able to receive a useful error message.

-1

Even though this question is a year old, and I can't give the exact reason for what's going wrong, I'd like to share what I know about this error, since there's almost no discussion of it elsewhere.

"Cannot get diagnostic message" consistently appears when the diagnostic message is too large. E.g. if you attempt an executemany on 20,000 rows, and a primary key violation occurs on each one, you can expect this error.

My advice is to try the same operation with a smaller subset of data. This should help you receive a useful diagnostic message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.