473,385 Members | 1,890 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,385 software developers and data experts.

mxODBC

What is wrong with the following attempt to perform an SQL INSERT? No error
is thrown but no data is inserted into table FRED in the database.
Especially odd is that SELECT statements work! The database is MS SQL Server
2000.

Thanks!

import mx.DateTime, mx.ODBC.Windows

if __name__ == '__main__':
rc = 0
connection = mx.ODBC.Windows.DriverConnect(
'dsn=CNB;userid=Administrator' ) # connect to database
cAddAction = connection.cursor()
ActionID = "12345"
ProcessID = 100
sAddActionQuery = "INSERT INTO FRED (ActionID, ProcessID) VALUES (%s,
%d)" % (ActionID, ProcessID)
print "ActionID=" + ActionID
print "ProcessID=" + str(ProcessID) + "<BR>"
try:
cAddAction.execute(sAddActionQuery)
except:
print "INSERT error<BR>"
cAddAction.close()
cAddAction = None
connection.close()
connection = None
Jul 18 '05 #1
2 1887
Andrew Chalk wrote:
What is wrong with the following attempt to perform an SQL INSERT? No error
is thrown but no data is inserted into table FRED in the database.
Especially odd is that SELECT statements work! The database is MS SQL Server
2000. [...]


You don't seem to commit the transaction. Invoke .commit() on the
connection object to do so.

-- Gerhard

Jul 18 '05 #2
Thanks! You're a hero, Gerhard.

"Gerhard Häring" <gh@ghaering.de> wrote in message
news:ma**********************************@python.o rg...
Andrew Chalk wrote:
What is wrong with the following attempt to perform an SQL INSERT? No error is thrown but no data is inserted into table FRED in the database.
Especially odd is that SELECT statements work! The database is MS SQL Server 2000. [...]


You don't seem to commit the transaction. Invoke .commit() on the
connection object to do so.

-- Gerhard

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: BartlebyScrivener | last post by:
Hello, I'm new to python and trying to get records from an MSAccess database using mxODBC. It works, but the output is not formatted the way I want it. Here's the script: import...
1
by: BartlebyScrivener | last post by:
This can't be the most elegant way to get a command line parameter into an sql query. It works but I can't explain why. Is there another, more correct way? Here sys.argv is a topic like "laugher"...
0
by: erik.myllymaki | last post by:
I am using a script that's worked for me in the past on Windows, but now that i've moved it to a Linux machine it is not. The trouble seems to be when trying to insert escaped characters into a ...
1
by: Sean Davis | last post by:
I have just installed mxODBC on my x86_64 suse linux machine, where I use unixODBC for connection. Running queries from isql or DataManager works fine for the DSN that I am using. However, under...
0
bartonc
by: bartonc | last post by:
With one small change to the view/control: self.staticText3 = wx.StaticText(id=wxID_DBCONNECTDIALOGSTATICTEXT3, label='ODBC Data Source Name', name='staticText3',...
3
by: Greg Corradini | last post by:
Hello, I'm trying to perform a simple insert statement into a table called Parcel_Test (see code below). Yet, I get an error message that I've never seen before (see traceback below). I've tried...
0
bartonc
by: bartonc | last post by:
This is a work in progress (current and active). There are some issues to resolve in supporting multiple connection types and I plan to add PySQLite to the mix. The this update is due to my...
0
by: Terry Reedy | last post by:
FYI I initially parsed the subject line as "eGenix mxODBC - ODBC Database Interface" for "Python 3.0.2" and thought, "Wow, already prepared for the future" (6 months to a year) ;-). tjr
0
by: eGenix Team: M.-A. Lemburg | last post by:
On 2008-10-15 20:30, Terry Reedy wrote: It's going to look even better when we release version 4.0 in a year or so ;-) FWIW, we're still waiting for the dust to settle before going for a Py3k...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.