Joel Bard | 17 Jul 21:48

insert fails with no error

Hi-

I'm connecting from linux x86_64 to a sqlserver2005 instance using mxODBC 3.0.1 with unixODBC.  I'm able to
retrieve data with no problem.  When I try a simple insert:

        c=db.cursor()
        p1="test"
        p2="mxodbc test"
        c.execute("insert into bug" + \
                  " (UIElement,Description)" + \
                  "values (?,?)" \
                  ,(p1,p2) \
                  )

c.rowcount is 1 but the row is not present in the table.  If I execute the same sql command using isql it works. 
The table uses an autoincrement key column and values for the key are consumed even though the record is not
being created.  c.messages is empty.  The same behavior is seen regardless of whether parameters are used
and regardless of wether I use execute or executedirect.  Any help would be appreciated.

Thanks,

Joel

_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users

Jim Vickroy | 17 Jul 22:15
Favicon

Re: insert fails with no error

Joel Bard wrote:
> Hi-
>
> I'm connecting from linux x86_64 to a sqlserver2005 instance using mxODBC 3.0.1 with unixODBC.  I'm able
to retrieve data with no problem.  When I try a simple insert:
>
>
>         c=db.cursor()
>         p1="test"
>         p2="mxodbc test"
>         c.execute("insert into bug" + \
>                   " (UIElement,Description)" + \
>                   "values (?,?)" \
>                   ,(p1,p2) \
>                   )
>
> c.rowcount is 1 but the row is not present in the table.  If I execute the same sql command using isql it works. 
The table uses an autoincrement key column and values for the key are consumed even though the record is not
being created.  c.messages is empty.  The same behavior is seen regardless of whether parameters are used
and regardless of wether I use execute or executedirect.  Any help would be appreciated.
>
> Thanks,
>
> Joel
>
>
>
>
> _______________________________________________________________________
> eGenix.com User Mailing List                     http://www.egenix.com/
(Continue reading)

Joel Bard | 17 Jul 22:28

Re: insert fails with no error

Thanks!  That was it.  Adding db.commit() at the end made it work.
 
Best Regards,
 
Joel

>>> Jim Vickroy <Jim.Vickroy-32lpuo7BZBA@public.gmane.org> 7/17/2008 4:15 PM >>>
Joel Bard wrote:
> Hi-
>
> I'm connecting from linux x86_64 to a sqlserver2005 instance using mxODBC 3.0.1 with unixODBC.  I'm able to retrieve data with no problem.  When I try a simple insert:
>
>
>         c=db.cursor()
>         p1="test"
>         p2="mxodbc test"
>         c.execute("insert into bug" + \
>                   " (UIElement,Description)" + \
>                   "values (?,?)" \
>                   ,(p1,p2) \
>                   )
>
> c.rowcount is 1 but the row is not present in the table.  If I execute the same sql command using isql it works.  The table uses an autoincrement key column and values for the key are consumed even though the record is not being created.  c.messages is empty.  The same behavior is seen regardless of whether parameters are used and regardless of wether I use execute or executedirect.  Any help would be appreciated.
>
> Thanks,
>
> Joel
>
>
>
>
> _______________________________________________________________________
> eGenix.com User Mailing List                     http://www.egenix.com/
> https://www.egenix.com/mailman/listinfo/egenix-users
>  
Hi Joel,

Is this perhaps a transactional issue?  Have you tried to explicitly
commit the insert transaction?

-- jv

Disclaimer: I not an mx.ODBC user -- just a "lurker".


_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users
M.-A. Lemburg | 17 Jul 22:50
Favicon

Re: insert fails with no error

On 2008-07-17 21:49, Joel Bard wrote:
> Hi-
> 
> I'm connecting from linux x86_64 to a sqlserver2005 instance using mxODBC 3.0.1 with unixODBC.  I'm able
to retrieve data with no problem.  When I try a simple insert:
> 
> 
>         c=db.cursor()
>         p1="test"
>         p2="mxodbc test"
>         c.execute("insert into bug" + \
>                   " (UIElement,Description)" + \
>                   "values (?,?)" \
>                   ,(p1,p2) \
>                   )
> 
> c.rowcount is 1 but the row is not present in the table.  If I execute the same sql command using isql it works. 
The table uses an autoincrement key column and values for the key are consumed even though the record is not
being created.  c.messages is empty.  The same behavior is seen regardless of whether parameters are used
and regardless of wether I use execute or executedirect.  Any help would be appreciated.

Jim already pointed you to the solution.

I just want to add for reference that isql defaults to working in auto-
commit mode, so all changes you make via isql will immediately be written
to the database.

mxODBC, on the other hand, defaults to transactional mode, so changes
will only be visible if you explicitly commit them to the database.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jul 17 2008)
 >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
 >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
 >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::

    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611

_______________________________________________________________________
eGenix.com User Mailing List                     http://www.egenix.com/
https://www.egenix.com/mailman/listinfo/egenix-users


Gmane