mxODBC

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andrew Chalk

    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.curs or()
    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.exec ute(sAddActionQ uery)
    except:
    print "INSERT error<BR>"
    cAddAction.clos e()
    cAddAction = None
    connection.clos e()
    connection = None


  • Gerhard Häring

    #2
    Re: mxODBC

    Andrew Chalk wrote:[color=blue]
    > 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. [...][/color]

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

    -- Gerhard

    Comment

    • Andrew Chalk

      #3
      Re: mxODBC

      Thanks! You're a hero, Gerhard.

      "Gerhard Häring" <gh@ghaering.de > wrote in message
      news:mailman.10 65025575.15333. python-list@python.org ...[color=blue]
      > Andrew Chalk wrote:[color=green]
      > > What is wrong with the following attempt to perform an SQL INSERT? No[/color][/color]
      error[color=blue][color=green]
      > > 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[/color][/color]
      Server[color=blue][color=green]
      > > 2000. [...][/color]
      >
      > You don't seem to commit the transaction. Invoke .commit() on the
      > connection object to do so.
      >
      > -- Gerhard
      >[/color]


      Comment

      Working...