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


Groups > comp.lang.python > #48586

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

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'insert': 0.05; 'mrab': 0.05; 'affected': 0.07; 'remaining': 0.07; '??,': 0.09; 'cookie': 0.09; 'data:': 0.09; 'filename': 0.09; 'filenames': 0.09; 'filenames:': 0.09; 'host,': 0.09; 'insertion': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'try:': 0.09; '%s,': 0.16; "'print':": 0.16; '(filename,': 0.16; '(host,': 0.16; '>the': 0.16; 'attribute.': 0.16; 'filename)': 0.16; 'hits': 0.16; 'message-id:@4ax.com': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reload': 0.16; 'subject:failed': 0.16; 'wrote:': 0.18; 'commit': 0.19; '>>>': 0.22; 'select': 0.22; 'print': 0.22; 'skip': 0.24; 'url:home': 0.24; 'shown': 0.26; 'pass': 0.26; 'values': 0.27; 'gets': 0.27; 'header:X-Complaints-To:1': 0.27; 'host': 0.29; 'database,': 0.30; 'lines': 0.31; '>>>>': 0.31; 'values.': 0.31; 'writes:': 0.31; 'file': 0.32; 'subject:time': 0.33; 'table': 0.34; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'doing': 0.36; 'next': 0.36; 'method': 0.36; 'shows': 0.36; 'charset:us-ascii': 0.36; 'turn': 0.37; 'received:76': 0.38; 'whatever': 0.38; 'to:addr:python- list': 0.38; 'files': 0.38; 'fact': 0.38; 'anything': 0.39; 'does': 0.39; 'delete': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'how': 0.40; 'increased': 0.61; 'john': 0.61; 'first': 0.61; 'dont': 0.67; 'records': 0.73; 'instantly': 0.84; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Updating a filename's counter value failed each time
Date Mon, 17 Jun 2013 21:42:00 -0400
Organization IISS Elusive Unicorn
References <kpne3k$1066$1@news.ntua.gr> <kpnnfu$t2i$1@reader1.panix.com> <kpno1h$std$1@news.grnet.gr> <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>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-249-27-103.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3503.1371519731.3114.python-list@python.org> (permalink)
Lines 78
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371519731 news.xs4all.nl 15881 [2001:888:2000:d::a6]:36095
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:48586

Show key headers only | View raw


On Tue, 18 Jun 2013 02:11:55 +0300, ????? <support@superhost.gr> declaimed
the following:

>???? 18/6/2013 1:22 ??, ?/? MRAB ??????:
>> On 17/06/2013 21:44, John Gordon wrote:
>>> In <MtKvt.47400$ja6.35986@fx18.am4> Alister
>>> <alister.ware@ntlworld.com> writes:
>>>
>>>> > #update file's counter if cookie does not exist cur.execute('''UPDATE
>>>> > files SET hits = hits + 1, host = %s, lastvisit =
>>>> > %s WHERE url = %s''', (host, lastvisit, filename) )
>>>> >
>>>> > if cur.rowcount:
>>>> >         print( " database has been affected" )
>>>> >
>>>> > indeed every time i select afilename the message gets printed bu then
>>>> > again noticing the database via phpmyadmin the filename counter is
>>>> > always remaining 0, and not added by +1
>>>
>>>> replase
>>>>  if cur.rowcount:
>>>>          print( " database has been affected" )
>>>
>>>> with print cur.rowcount()
>>>
>>> rowcount isn't a method call; it's just an attribute.  You don't need
>>> the parentheses.
>>>
>> Well, you do need parentheses, it's just that you need them around the
>> 'print':
>>
>> if cur.rowcount:
>>      print(cur.rowcount)
>>
>Okey print( cur.rowcount ) shows each time a select a fialenme from the 
>html table for downlaod that update affected 1 row.
>
>Checking the database records instantly shown that in fact the counter 
>was increased by +1
>
>Runing files.py turn all counter values to 0.
>
>So, update works, its the reload of files.py the deleets the values.
>
># Delete those database records that do not exist as filenames inside 
>the path
>for rec in data:
>	if rec not in filenames:
>		cur.execute('''DELETE FROM files WHERE url = %s''', rec )
>
># Load'em
>for filename in filenames:
>	try:
>		# try to insert the file into the database
>		cur.execute('''INSERT INTO files (url, host, lastvisit) VALUES (%s, 
>%s, %s)''', (filename, host, lastvisit) )
>	except pymysql.ProgrammingError as e:
>		# Insertion failed, file already into database, skip this, go to next 
>filename
>		pass
>
>These lines i dont how but they "manage" not to maintain the counter's value
>
>-- 
>What is now proved was at first only imagined!

	Just out of curiosity... 

	Do you ever COMMIT the changes.

	cur.execute("update anything set something = whatever where that =
this")

without doing a con.commit() is just going to rollback the 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