288a395eddbc70ae7e3ccbdf04a0b50fc730903d
8 config
= ConfigParser
.RawConfigParser()
9 config
.read('/etc/dylanstestserver.ini')
10 domain
= config
.get('database', 'domain')
11 user
= config
.get('database', 'user')
12 password
= config
.get('database', 'password')
13 database
= config
.get('database', 'database')
14 cursor
= db
.connect(domain
, user
, password
, database
).cursor()
16 notes
= os
.listdir('/home/dylan/docs/notes')
18 sql
= "SELECT title FROM notes"
20 results
= cursor
.fetchall()
23 existing_titles
.append(row
[0])
26 if note
== 'index.php' or note
== 'notes.php': continue
27 url
= note
[:note
.index('.')]
28 f
= open(os
.path
.join('notes', note
))
29 title
= str(f
.readline()[:-1])
30 text
= ''.join(f
.readlines()) #converts list to single string
31 if title
in existing_titles
: continue
32 mtime
= time
.localtime(os
.path
.getmtime(os
.path
.join('notes', note
)))
33 date_posted
= "%s-%s-%s" % (str(mtime
.tm_year
)[2:], mtime
.tm_mon
, mtime
.tm_mday
)
34 sql
= "INSERT INTO notes (date_posted, url, title, text)\
35 VALUES(\"%s\", \"%s\", \"%s\", \"%s\")"\
36 % (date_posted
, url
, title
, db
.escape_string(text
))