471,342 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,342 software developers and data experts.

pymssql - insert NULL to int

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.

Oct 17 '07 #1
3 5839
rc wrote:
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
Oct 17 '07 #2
rc
On Oct 17, 11:07 am, "Diez B. Roggisch" <de...@nospam.web.dewrote:
rc wrote:
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
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

Oct 17 '07 #3
rc wrote:
On Oct 17, 11:07 am, "Diez B. Roggisch" <de...@nospam.web.dewrote:
>rc wrote:
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

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
Oct 18 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Khawaja Shahzad Sadiq Butt | last post: by
reply views Thread by saqib | last post: by
1 post views Thread by morris carre | last post: by
1 post views Thread by m.biddiscombe | last post: by
7 posts views Thread by ChaosKCW | last post: by
reply views Thread by Aspersieman | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.