Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > mxODBC

Reply
Thread Tools

mxODBC

 
 
Andrew Chalk
Guest
Posts: n/a
 
      10-01-2003
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


 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Gerhard_H=E4ring?=
Guest
Posts: n/a
 
      10-01-2003
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

 
Reply With Quote
 
 
 
 
Andrew Chalk
Guest
Posts: n/a
 
      10-01-2003
Thanks! You're a hero, Gerhard.

"Gerhard Häring" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ANN: eGenix mxODBC and mxODBC Zope DA on AIX 5.3 (and later) eGenix Team: M.-A. Lemburg Python 0 11-19-2007 12:43 PM
ANN: eGenix mxODBC and mxODBC Zope DA on 64-bit FreeBSD eGenix Team: M.-A. Lemburg Python 0 09-12-2007 03:23 PM
ANN: eGenix mxODBC Distribution 3.0.1 (mxODBC Database Interface) eGenix Team: M.-A. Lemburg Python 0 08-22-2007 12:59 PM
ANN: eGenix mxODBC 3.0 Developer Licenses (mxODBC Database Interface) eGenix Team: M.-A. Lemburg Python 0 05-29-2007 03:33 PM
ANN: eGenix mxODBC Distribution 3.0.0 (mxODBC Database Interface) eGenix Team: M.-A. Lemburg Python 1 05-11-2007 01:55 AM



Advertisments