Downloading a file form a displayed table

Joel Goldstick joel.goldstick at gmail.com
Tue Mar 5 08:38:28 EST 2013


On Tue, Mar 5, 2013 at 8:01 AM, Νίκος Γκρ33κ <nikos.gr33k at gmail.com> wrote:

> Please help me correct thois code, iam tryign ti for hours and i cant seem
> to get it working....it irritates me....
>

There is no question here.  No indication of what isn't working as you
like.  No traceback.

>
> path = "/home/nikos/public_html/data/files/"
> for filename in os.walk(path):
>         try:
>                 #find the needed counter for the page URL
>                 cur.execute('''SELECT ID FROM files WHERE URL = %s''',
> (filename,) )
>                 data = cur.fetchone()        #URL is unique, so should
> only be one
>
>                 if not data:
>                         #first time for page; primary key is automatic,
> hit is defaulted
>                         cur.execute('''INSERT INTO files (URL, lastvisit)
> VALUES (%s, %s)''', (filename, date) )
>                         cID = cur.lastrowid        #get the primary key
> value of the new record
>                 else:
>                         #found the page, save primary key and use it to
> issue hit UPDATE
>                         cID = data[0]
>                         cur.execute('''UPDATE files SET hits = hits + 1,
> lastvisit = %s WHERE ID = %s''', (date, cID)
>         except MySQLdb.Error, e:
>                 print ( "Query Error: ", sys.exc_info()[1].excepinfo()[2] )
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
http://joelgoldstick.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130305/82ed6c95/attachment.html>


More information about the Python-list mailing list