Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #48588

Re: Updating a filename's counter value failed each time

From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Updating a filename's counter value failed each time
Date 2013-06-17 22:01 -0400
Organization IISS Elusive Unicorn
References (3 earlier) <MtKvt.47400$ja6.35986@fx18.am4> <kpnsej$8v4$1@reader1.panix.com> <mailman.3496.1371507741.3114.python-list@python.org> <kpo53s$sa6$1@news.grnet.gr> <5eevr89n3cqg6k948pvqqhtfhfj4s0tnk5@4ax.com>
Newsgroups comp.lang.python
Message-ID <mailman.3504.1371520901.3114.python-list@python.org> (permalink)

Show all headers | View raw


On Mon, 17 Jun 2013 21:42:00 -0400, Dennis Lee Bieber
<wlfraed@ix.netcom.com> declaimed the following:


	I'm not going to inflict the group with the whole quote again, but...
What does the documentation for your db-api adapter (hmmm... have I even
installed one on my new computer <G>) indicate may happen if you get an
exception when adding a record? Hopefully it leaves the choice of rollback
vs commit up to you.

	In pseudo-code:

con = db.connect(...)
cur = con.cursor()

for f in data:
	if f not in somelist:
		cur.execute("delete from table where field = %s",
					f)
con.commit()	#make deletes permanent in database

for f in otherdata:
	cur.execute("select * from table where field = %s", f)
	#while a try/except:pass might have the same result,
	#if you don't check for details it could hide OTHER errors
	if not cur.fetchall():
		#record not found in database, go ahead and add it
		cur.execute("insert into table (x, y, z) values (%s, %s, %s)",
					(a, b, c)	)
con.commit()

	If you don't commit, and just exit the program, the database will throw
away all your changes.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Updating a filename's counter value failed each time Simpleton <support@superhost.gr> - 2013-06-17 19:39 +0300
  Re: Updating a filename's counter value failed each time MRAB <python@mrabarnett.plus.com> - 2013-06-17 18:40 +0100
    Re: Updating a filename's counter value failed each time Νίκος <support@superhost.gr> - 2013-06-17 20:51 +0300
  Re: Updating a filename's counter value failed each time John Gordon <gordon@panix.com> - 2013-06-17 17:40 +0000
  Re: Updating a filename's counter value failed each time jt@toerring.de (Jens Thoms Toerring) - 2013-06-17 17:54 +0000
    Re: Updating a filename's counter value failed each time Νίκος <support@superhost.gr> - 2013-06-17 21:06 +0300
      Re: Updating a filename's counter value failed each time jt@toerring.de (Jens Thoms Toerring) - 2013-06-17 18:32 +0000
        Re: Updating a filename's counter value failed each time MRAB <python@mrabarnett.plus.com> - 2013-06-17 19:47 +0100
          Re: Updating a filename's counter value failed each time jt@toerring.de (Jens Thoms Toerring) - 2013-06-17 19:16 +0000
            Re: Updating a filename's counter value failed each time Alister <alister.ware@ntlworld.com> - 2013-06-17 20:33 +0000
      Re: Updating a filename's counter value failed each time Alister <alister.ware@ntlworld.com> - 2013-06-17 19:05 +0000
        Re: Updating a filename's counter value failed each time Νίκος <support@superhost.gr> - 2013-06-17 22:30 +0300
          Re: Updating a filename's counter value failed each time Alister <alister.ware@ntlworld.com> - 2013-06-17 20:26 +0000
            Re: Updating a filename's counter value failed each time Alister <alister.ware@ntlworld.com> - 2013-06-17 20:43 +0000
    Re: Updating a filename's counter value failed each time Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-17 19:30 -0400
      Re: Updating a filename's counter value failed each time Νίκος <support@superhost.gr> - 2013-06-18 03:25 +0300
  Re: Updating a filename's counter value failed each time John Gordon <gordon@panix.com> - 2013-06-17 19:19 +0000
    Re: Updating a filename's counter value failed each time Νίκος <support@superhost.gr> - 2013-06-17 22:28 +0300
      Re: Updating a filename's counter value failed each time Alister <alister.ware@ntlworld.com> - 2013-06-17 20:39 +0000
        Re: Updating a filename's counter value failed each time John Gordon <gordon@panix.com> - 2013-06-17 20:44 +0000
          Re: Updating a filename's counter value failed each time Alister <alister.ware@ntlworld.com> - 2013-06-17 20:49 +0000
          Re: Updating a filename's counter value failed each time MRAB <python@mrabarnett.plus.com> - 2013-06-17 23:22 +0100
            Re: Updating a filename's counter value failed each time Νίκος <support@superhost.gr> - 2013-06-18 02:11 +0300
              Re: Updating a filename's counter value failed each time Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-17 21:42 -0400
                Re: Updating a filename's counter value failed each time Νίκος <support@superhost.gr> - 2013-06-18 08:49 +0300
                Re: Updating a filename's counter value failed each time Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-18 19:56 -0400
              Re: Updating a filename's counter value failed each time Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-06-17 22:01 -0400
  Re: Updating a filename's counter value failed each time Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-17 23:18 +0000
  Re: Updating a filename's counter value failed each time Νίκος <support@superhost.gr> - 2013-06-18 03:22 +0300

csiph-web