Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > question about deleting records from mysql

Reply
Thread Tools

question about deleting records from mysql

 
 
nephish@xit.net
Guest
Posts: n/a
 
      07-27-2005
Hey there,
sorry , second question in as many days.
i am trying to do some stuff with MySQLdb and the thing is, i can
select records and such, but when i try to delete them, they dont
really go away.

like this

>>> cursor.execute("DELETE FROM table WHERE autoinc > 1000")

240L
>>> cursor.execute("SELECT * FROM table WHERE autoinc > 1000")

0L

so it looks like it worked, but when i use something else to look at
the
table (phpmyadmin, mysql-query-browser, knoda) the records are still
there!

what do i do?

 
Reply With Quote
 
 
 
 
Simon Brunning
Guest
Posts: n/a
 
      07-27-2005
On 27 Jul 2005 04:29:33 -0700, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> Hey there,
> sorry , second question in as many days.
> i am trying to do some stuff with MySQLdb and the thing is, i can
> select records and such, but when i try to delete them, they dont
> really go away.


A fiver says you need to commit your changes.

--
Cheers,
Simon B,
(E-Mail Removed),
http://www.brunningonline.net/simon/blog/
 
Reply With Quote
 
 
 
 
nephish
Guest
Posts: n/a
 
      07-27-2005
Simon Brunning wrote:

>On 27 Jul 2005 04:29:33 -0700, (E-Mail Removed) <(E-Mail Removed)> wrote:
>
>
>>Hey there,
>>sorry , second question in as many days.
>>i am trying to do some stuff with MySQLdb and the thing is, i can
>>select records and such, but when i try to delete them, they dont
>>really go away.
>>
>>

>
>A fiver says you need to commit your changes.
>
>
>

ok, do i do that with cursor.commit() ?
thanks
 
Reply With Quote
 
Mage
Guest
Posts: n/a
 
      07-27-2005
nephish wrote:

>Simon Brunning wrote:
>
>
>
>>On 27 Jul 2005 04:29:33 -0700, (E-Mail Removed) <(E-Mail Removed)> wrote:
>>
>>
>>
>>
>>>Hey there,
>>>sorry , second question in as many days.
>>>i am trying to do some stuff with MySQLdb and the thing is, i can
>>>select records and such, but when i try to delete them, they dont
>>>really go away.
>>>
>>>
>>>
>>>

>>A fiver says you need to commit your changes.
>>
>>
>>
>>
>>

>ok, do i do that with cursor.commit() ?
>thanks
>
>

Yes, or maybe you should write a lightweight layer between the dbapi and
your program which can turn on and off the autocommit by calling
"commit" and "begin" as query. I did this in my pgsql layer. Using
transactions every time is almost as bad as never using them.

Mage

 
Reply With Quote
 
nephish@xit.net
Guest
Posts: n/a
 
      07-27-2005
ok. did this

>>> cursor.execute("DELETE FROM table WHERE autoinc > 1000")

245L
>>> cursor.commit()


i got an AttributeError 'Cursor' object has no attribute 'commit'

hmm. what should i do now?
the stuff about writing a lightweight layer between the dbapi and the
program shot right over my head. sorry, but thanks

 
Reply With Quote
 
Roman Neuhauser
Guest
Posts: n/a
 
      07-27-2005
# (E-Mail Removed) / 2005-07-27 05:12:46 -0700:
> ok. did this
>
> >>> cursor.execute("DELETE FROM table WHERE autoinc > 1000")

> 245L
> >>> cursor.commit()

>
> i got an AttributeError 'Cursor' object has no attribute 'commit'
>
> hmm. what should i do now?


RTFM, e. g. here:

http://cvs.sourceforge.net/viewcvs.p...=1.1&view=auto

--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
 
Reply With Quote
 
Rowdy
Guest
Posts: n/a
 
      07-27-2005
(E-Mail Removed) wrote:
> ok. did this
>
>
>>>>cursor.execute("DELETE FROM table WHERE autoinc > 1000")

>
> 245L
>
>>>>cursor.commit()

>
>
> i got an AttributeError 'Cursor' object has no attribute 'commit'
>
> hmm. what should i do now?
> the stuff about writing a lightweight layer between the dbapi and the
> program shot right over my head. sorry, but thanks
>


IIRC it is the connection that can commit(), not the cursor.

Rowdy
 
Reply With Quote
 
nephish
Guest
Posts: n/a
 
      07-27-2005
Man, thanks for the link. and the tip. i am testing
the db.commit() and printing the doc right now.
thanks again.


On 07/27/2005 07:43:24 AM, Rowdy wrote:
> (E-Mail Removed) wrote:
>> ok. did this
>>
>>
>>>>> cursor.execute("DELETE FROM table WHERE autoinc > 1000")

>>
>> 245L
>>
>>>>> cursor.commit()

>>
>>
>> i got an AttributeError 'Cursor' object has no attribute 'commit'
>>
>> hmm. what should i do now?
>> the stuff about writing a lightweight layer between the dbapi and the
>> program shot right over my head. sorry, but thanks
>>

>
> IIRC it is the connection that can commit(), not the cursor.
>
> Rowdy
>


 
Reply With Quote
 
Cantankerous Old Git
Guest
Posts: n/a
 
      07-27-2005
nephish wrote:
> Man, thanks for the link. and the tip. i am testing
> the db.commit() and printing the doc right now.
> thanks again.


If it's any help, using

cursor.execute("set autocommit = 1")

before doing anything else works nicely unless you actually need
transactions.

The Cog
 
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
Simple query returns 0 records in asp, but all records in vbscript masg0013@gmail.com ASP General 3 11-02-2006 09:23 AM
Newbie question - deleting records from anydbm database Dan M Python 2 12-15-2005 01:54 PM
Deleting multiple records(rows) from tables using checkboxes Patrick.O.Ige ASP .Net 0 11-03-2005 11:41 PM
Delete records or update records Dan ASP General 1 05-10-2004 01:25 PM
match muliple header records to associated detail records Luke Airig XML 0 12-31-2003 12:06 AM



Advertisments