7 db
= MySQLdb
.connect('localhost','dylan','password', 'dylanstestserver')
10 notes
= os
.listdir('notes')
12 sql
= "SELECT title FROM notes"
14 results
= cursor
.fetchall()
17 existing_titles
.append(row
[0])
20 if note
== 'index.php' or note
== 'notes.php': continue
21 url
= note
[:note
.index('.')]
22 f
= open(os
.path
.join('notes', note
))
23 title
= str(f
.readline()[:-1])
24 text
= ''.join(f
.readlines()) #converts list to single string
25 if title
in existing_titles
: continue
26 mtime
= time
.localtime(os
.path
.getmtime(os
.path
.join('notes', note
)))
27 date_posted
= "%s-%s-%s" % (str(mtime
.tm_year
)[2:], mtime
.tm_mon
, mtime
.tm_mday
)
28 sql
= "INSERT INTO notes (date_posted, url, title, text)\
29 VALUES(\"%s\", \"%s\", \"%s\", \"%s\")"\
30 % (date_posted
, url
, title
, MySQLdb
.escape_string(text
))