473,287 Members | 1,793 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 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 6159
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Khawaja Shahzad Sadiq Butt | last post by:
Hi, I am trying to connect to sql server 2000 on win xp. I am using a python extension called. pymssql but it is giving me this errror: Traceback (most recent call last): File...
0
by: saqib | last post by:
I have a query that is running on a mssql DB that takes about 15 minutes when run "directly"; IE: thru MS SQL Query Analyzer. I know, it sucks. I'm trying to fix it. But in the meantime, I have...
1
by: morris carre | last post by:
I have a strange problem : some code that fetches queries from an mssql database works fine under Idle but the very same code run from a shell window obtains its strings garbled as if the encoding...
1
by: m.biddiscombe | last post by:
Hi, I'm trying to use pymssql to execute a stored procedure. Currently, I have an Excel spreadsheet that uses VBA in this manner: Private Function CreateNewParrot(connDb As ADODB.Connection)...
4
by: gdyren | last post by:
the code is below: import pymssql conn = pymssql.connect(host = "121.198.126.233",user = "xxxx",password = "xxxx",database = "test") print "connecting success" cursor = conn.cursor()...
7
by: ChaosKCW | last post by:
Hi I am trying to use pymssql, and have an issue where by the execute (not the fetch) is appearing to load all records into memory. if I execute con = pymssql.connect(...) cur =...
0
by: Aspersieman | last post by:
On Tue, 21 Oct 2008 20:44:24 +0200, Mike Hansen <projecktzero@yahoo.com> wrote: Hi there I hope you don't mind - I made this a new thread on the list, so others can maybe help out. ...
1
by: Darren Mansell | last post by:
Hi. I'm relatively new to python so please be gentle :) I'm trying to write a £ symbol to an MS SQL server using pymsssql . This works but when selecting the data back (e.g. using SQL...
0
by: Darren Mansell | last post by:
On Mon, 2008-11-17 at 15:24 +0000, Tim Golden wrote: Thanks for the help. Unfortunately pyodbc seems to only work on Windows. I need to connect to the SQL server from a Linux box. The db...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

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.