Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40525
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-03-05 05:01 -0800 |
| References | <f99ae3d5-6f1f-4dfc-84da-78b758a5147a@googlegroups.com> |
| Message-ID | <ebde8f97-46c4-49c6-a0e1-7056455352d7@googlegroups.com> (permalink) |
| Subject | Re: Downloading a file form a displayed table |
| From | Νίκος Γκρ33κ <nikos.gr33k@gmail.com> |
Please help me correct thois code, iam tryign ti for hours and i cant seem to get it working....it irritates me....
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] )
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 01:00 -0800
Re: Downloading a file form a displayed table Dave Angel <davea@davea.name> - 2013-03-05 04:45 -0500
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 01:48 -0800
Re: Downloading a file form a displayed table Dave Angel <davea@davea.name> - 2013-03-05 05:05 -0500
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 01:48 -0800
Re: Downloading a file form a displayed table Dave Angel <davea@davea.name> - 2013-03-05 04:51 -0500
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 02:24 -0800
Re: Downloading a file form a displayed table Lele Gaifax <lele@metapensiero.it> - 2013-03-05 12:29 +0100
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 02:24 -0800
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 05:01 -0800
Re: Downloading a file form a displayed table Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-05 08:38 -0500
Re: Downloading a file form a displayed table "Vytas D." <vytasd2013@gmail.com> - 2013-03-05 13:38 +0000
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 06:37 -0800
Re: Downloading a file form a displayed table Νίκος Γκρ33κ <nikos.gr33k@gmail.com> - 2013-03-05 06:37 -0800
Re: Downloading a file form a displayed table Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-05 14:04 +0000
csiph-web