mxODBC
Andrew Chalk
achalk at XXXmagnacartasoftware.com
Wed Oct 1 12:12:06 EDT 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
More information about the Python-list
mailing list