473,793 Members | 2,948 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Databas eError: 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 6213
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.Databas eError: 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.w eb.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.Databas eError: 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.w eb.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.Databas eError: 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
1531
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 "C:\Python22\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\syndication\db_1.py", line 3, in ?
0
1563
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 a python process which connects to the DB using pymssql. This process runs the aformentioned query... but fails because the query times out after approx 30 seconds. Is there anyway to change/set the timeout setting on a pymssql DB connection?? I...
1
2849
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 codepage was modified. This occurs only when using pymssql to connect; if I connect through odbc (using the odbc module included in pywin) this problem vanishes. I briefly thought sys.getdefaultencoding() would pin it down but the value is...
1
6714
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) As Long Dim objCommand As ADODB.Command Dim iParrot As Long Dim bSuccess As Boolean
4
1294
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() cursor.execute("insert into bbs_test values(%s,%s,%s,%s,%s)", ("1","nju","9:13","ustc","test")) cursor.close() conn.close()
7
6690
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 = con.cursor() cur.execute(sql)
0
1431
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. Although I use Linux quite often, I'm afraid MS SQL (with python) from
1
3415
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 management studio) the £ symbol is replaced with £ (latin capital letter A with circumflex). I can reproduce it like so:
0
1318
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 schema is very set in stone, I can't do anything with it. I'm currently opening autogenerated SQL scripts, decoding them from utf-16 and then back into utf-8 for pymssql to run them. It's been working great for ages until someone noticed the £...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10430
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10159
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.