Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48512
| From | Simpleton <support@superhost.gr> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Why 'files.py' does not print the filenames into a table format? |
| Date | 2013-06-17 13:26 +0300 |
| Organization | National Technical University of Athens, Greece |
| Message-ID | <kpmo7p$20d$1@news.ntua.gr> (permalink) |
| References | (3 earlier) <mailman.3407.1371328673.3114.python-list@python.org> <kpm8hg$250s$3@news.ntua.gr> <kpm99p$250s$4@news.ntua.gr> <51beb3f8$0$29872$c3e8da3$5496439d@news.astraweb.com> <kpmjl5$1l21$1@news.ntua.gr> |
On 17/6/2013 12:07 μμ, Simpleton wrote:
> On 17/6/2013 10:00 πμ, Steven D'Aprano wrote:
>> On Mon, 17 Jun 2013 09:11:05 +0300, Νίκος wrote:
>>
>>> everything work as expected but not the part when the counter of a
>>> filename gets increased when the file have been requested.
>>>
>>> I don't see how since:
>>>
>>> if filename:
>>> #update file counter
>>> cur.execute('''UPDATE files SET hits = hits + 1, host = %s,
>>> lastvisit = %s WHERE url = %s''', (host, lastvisit, filename) )
>>
>>
> There isn'tmuch to say ehre. You already know the code that im using
> inside files.pu and the question is that this execute never gets to
> execute.
>
> #
> =================================================================================================================
>
> # Make sure that ALL database records are filenames in existance
> #
> =================================================================================================================
>
> filenames = []
>
> # Switch filenames from (utf8 bytestrings => unicode strings) and trim
> them from their paths
> for utf8_filename in utf8_filenames:
> filenames.append( utf8_filename.decode('utf-8').replace(
> '/home/nikos/public_html/data/apps/', '' ) )
>
> # Check the presence of a database file against the dir files and delete
> record if it doesn't exist
> cur.execute('''SELECT url FROM files''')
> data = cur.fetchall()
>
> # Delete spurious database records
> 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:
> # Check the presence of current filename against it's database
> presence
> cur.execute('''SELECT url FROM files WHERE url = %s''', filename )
> data = cur.fetchone()
>
> if not data:
> # First time for file; primary key is automatic, hit is
> defaulted
> cur.execute('''INSERT INTO files (url, host, lastvisit)
> VALUES (%s, %s, %s)''', (filename, host, lastvisit) )
> except pymysql.ProgrammingError as e:
> print( repr(e) )
>
>
> #
> =================================================================================================================
>
> # Display ALL files, each with its own download button
> #
> =================================================================================================================
>
> print('''<body background='/data/images/star.jpg'>
> <center><img src='/data/images/download.gif'><br><br>
> <table border=5 cellpadding=5 bgcolor=green>
> ''')
>
> try:
> cur.execute( '''SELECT * FROM files ORDER BY lastvisit DESC''' )
> data = cur.fetchall()
>
> for row in data:
> (filename, hits, host, lastvisit) = row
> lastvisit = lastvisit.strftime('%A %e %b, %H:%M')
>
> print('''
> <form method="get" action="/cgi-bin/files.py">
> <tr>
> <td> <center> <input type="submit" name="filename"
> value="%s"> </td>
> <td> <center> <font color=yellow size=5> %s </td>
> <td> <center> <font color=orange size=4> %s </td>
> <td> <center> <font color=silver size=4> %s </td>
> </tr>
> </form>
> ''' % (filename, hits, host, lastvisit) )
> print( '''</table><br><br>''' )
> except pymysql.ProgrammingError as e:
> print( repr(e) )
>
> sys.exit(0)
>
> After a spcific file gets selected then files.py is reloading grabbign
> the filename as a variable form and:
>
> #
> =================================================================================================================
>
> # If user downloaded a file, thank the user !!!
> #
> =================================================================================================================
>
> if filename:
> #update filename'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) )
>
> but the execute never happesn.
> i ahve tested it
>
> if data:
> print soemthing
>
> but data is always empty.
So any ideas why the update statements never gets executed?
--
What is now proved was at first only imagined!
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-15 22:38 +0300
Re: Why 'files.py' does not print the filenames into a table format? Jarrod Henry <jarrodhenry@gmail.com> - 2013-06-15 14:46 -0500
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-15 22:51 +0300
Re: Why 'files.py' does not print the filenames into a table format? Benjamin Schollnick <benjamin@schollnick.net> - 2013-06-15 16:29 -0400
Re: Why 'files.py' does not print the filenames into a table format? Joshua Landau <joshua.landau.ws@gmail.com> - 2013-06-15 21:37 +0100
Re: Why 'files.py' does not print the filenames into a table format? Νίκος <support@superhost.gr> - 2013-06-17 08:58 +0300
Re: Why 'files.py' does not print the filenames into a table format? Νίκος <support@superhost.gr> - 2013-06-17 09:11 +0300
Re: Why 'files.py' does not print the filenames into a table format? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-17 07:00 +0000
Re: Why 'files.py' does not print the filenames into a table format? Simpleton <support@superhost.gr> - 2013-06-17 12:07 +0300
Re: Why 'files.py' does not print the filenames into a table format? Simpleton <support@superhost.gr> - 2013-06-17 12:18 +0300
Re: Why 'files.py' does not print the filenames into a table format? Simpleton <support@superhost.gr> - 2013-06-17 13:26 +0300
Re: Why 'files.py' does not print the filenames into a table format? Chris Angelico <rosuav@gmail.com> - 2013-06-16 08:51 +1000
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:07 +0300
Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-16 05:06 +0000
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Nick the Gr33k <support@superhost.gr> - 2013-06-16 11:28 +0300
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-16 10:33 +0000
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Ferrous Cranus <support@superhost.gr> - 2013-06-16 13:57 +0300
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-16 12:09 +0100
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Ferrous Cranus <support@superhost.gr> - 2013-06-16 14:12 +0300
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-06-16 13:19 +0200
Re: Python Greek mailing list [was Re: Why 'files.py' does not print the filenames into a table format?] Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-06-16 13:03 +0200
Re: Why 'files.py' does not print the filenames into a table format? Ferrous Cranus <support@superhost.gr> - 2013-06-16 16:57 +0300
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:10 +0300
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:24 +0300
Re: Why 'files.py' does not print the filenames into a table format? Grant Edwards <invalid@invalid.invalid> - 2013-06-17 14:50 +0000
Re: Why 'files.py' does not print the filenames into a table format? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-15 22:29 +0100
Re: Why 'files.py' does not print the filenames into a table format? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-16 00:10 +0000
Re: Why 'files.py' does not print the filenames into a table format? alex23 <wuwei23@gmail.com> - 2013-06-16 17:04 -0700
Re: Why 'files.py' does not print the filenames into a table format? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-17 01:31 +0100
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:03 +0300
Re: Why 'files.py' does not print the filenames into a table format? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-16 02:10 +0100
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 04:28 +0300
Re: Why 'files.py' does not print the filenames into a table format? Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-16 07:23 +0000
Re: Why 'files.py' does not print the filenames into a table format? Nick the Gr33k <support@superhost.gr> - 2013-06-16 11:35 +0300
Re: Why 'files.py' does not print the filenames into a table format? Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-16 08:55 +0000
Re: Why 'files.py' does not print the filenames into a table format? Ferrous Cranus <support@superhost.gr> - 2013-06-16 16:59 +0300
Re: Why 'files.py' does not print the filenames into a table format? jmfauth <wxjmfauth@gmail.com> - 2013-06-16 05:57 -0700
csiph-web