473,386 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

question about deleting records from mysql

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?

Jul 27 '05 #1
8 1999
On 27 Jul 2005 04:29:33 -0700, ne*****@xit.net <ne*****@xit.net> 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,
si***@brunningonline.net,
http://www.brunningonline.net/simon/blog/
Jul 27 '05 #2
Simon Brunning wrote:
On 27 Jul 2005 04:29:33 -0700, ne*****@xit.net <ne*****@xit.net> 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
Jul 27 '05 #3
nephish wrote:
Simon Brunning wrote:
On 27 Jul 2005 04:29:33 -0700, ne*****@xit.net <ne*****@xit.net> 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

Jul 27 '05 #4
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

Jul 27 '05 #5
# ne*****@xit.net / 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
Jul 27 '05 #6
ne*****@xit.net 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
Jul 27 '05 #7
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:
ne*****@xit.net 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


Jul 27 '05 #8
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
Jul 27 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tony Clarke | last post by:
Hi, Just a quick question about performance with MySQL & PHP. If I had a table in a MySQL database with about 100,000 records in it and I need to find the last record is there a quick way to do...
0
by: Karam Chand | last post by:
Greetings I manage a website wherein i keep track of the people email who have downloaded my software and the version number. the structure is like - id int auto_increment primary key,...
0
by: Mark Jay Johansen | last post by:
Does anyone know what the relative performance would be of using updateable result sets versus using individual insert or update statements? (Specifically at the moment I'm dealing with JSP...
2
by: R. Tarazi | last post by:
Hello, DB-structure: ========= firmendaten ----------------- firmendatenid <- firmennummer name strasse
7
by: Danny J. Lesandrini | last post by:
I know this has been discussed before, as I've seen the Google posts, but they all leave me with an unanswered question: Does my DAO code executed in the front end cause the back end to bloat?...
17
by: (PeteCresswell) | last post by:
I've got apps where you *really* wouldn't want to delete certain items by accident, but the users just have to have a "Delete" button. My current strategies: Plan A:...
2
by: azmiza | last post by:
Hi everybody, I need your help. I want to view my sql database and its work very well which is display in my web browser but once I want to press button yes, its not working, I check the...
10
by: JohnO | last post by:
Hi All, This question is related to iSeries V5R4 and db2. I want to implement an AFTER DELETE trigger to save the deleted rows to an archive table, I initially defined it as a FOR EACH...
1
by: pitjpz | last post by:
We have moved our Database to another server. The server it was on used SQL 4 and the new one its on now uses SQL5 the only problem we can find is that when you attempt to delete a record from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.