3 PROJECTS_DIRECTORY
= '/home/dylan/docs/projects'
10 config
= ConfigParser
.RawConfigParser()
11 config
.read('/etc/dylanstestserver.ini')
12 domain
= config
.get('database', 'domain')
13 user
= config
.get('database', 'user')
14 password
= config
.get('database', 'password').replace('"', '')
15 database
= config
.get('database', 'database')
16 cursor
= db
.connect(domain
, user
, password
, database
).cursor()
18 notes
= os
.listdir(PROJECTS_DIRECTORY
)
20 sql
= "SELECT title FROM projects"
22 results
= cursor
.fetchall()
25 existing_titles
.append(row
[0])
28 if (note
[:1] == '.'): continue
29 title
= note
[:note
.index('.')]
30 f
= open(os
.path
.join(PROJECTS_DIRECTORY
, note
))
31 if title
in existing_titles
: continue
33 cursor
.execute("INSERT INTO projects (title, text)\
34 VALUES (%s, %s)", (title
, text
))