pymssql - insert NULL to int

R

rc

How to insert NULL values in to int field using params.

I'm trying to use pymssql.execute, passing the operation and list of
params. One of the values in the params is a NULL value going to int
field. The pymssql._quote() puts ' around the NULL which causes an
exception to be thrown, is there a way to use the params for this or
do I need to build the insert string myself?

pymssql.DatabaseError: internal error: SQL Server message 245,
severity 16, state 1, line 1:
Conversion failed when converting the varchar value 'NULL' to data
type int.
DB-Lib error message 10007, severity 5:
General SQL Server error: Check messages from the SQL Server.
 
D

Diez B. Roggisch

rc said:
How to insert NULL values in to int field using params.

I'm trying to use pymssql.execute, passing the operation and list of
params. One of the values in the params is a NULL value going to int
field. The pymssql._quote() puts ' around the NULL which causes an
exception to be thrown, is there a way to use the params for this or
do I need to build the insert string myself?

pymssql.DatabaseError: internal error: SQL Server message 245,
severity 16, state 1, line 1:
Conversion failed when converting the varchar value 'NULL' to data
type int.
DB-Lib error message 10007, severity 5:
General SQL Server error: Check messages from the SQL Server.

Can you show us the actual code you use? I doubt that such a basic thing
isn't working.

You are aware that you have to pass None, not "NULL"?

Diez
 
R

rc

Can you show us the actual code you use? I doubt that such a basic thing
isn't working.

You are aware that you have to pass None, not "NULL"?

Diez

I had tried None and was getting the same error as 'NULL', however, I
tried again after your post and its working now. Not sure what I
changed but thanks for getting me to tried it again.

rc
 
D

Diez B. Roggisch

rc said:
I had tried None and was getting the same error as 'NULL', however, I
tried again after your post and its working now. Not sure what I
changed but thanks for getting me to tried it again.

I'm pretty sure you tried "None" instead of None

Diez
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top