[Tutor] Databases in Python

aug dawg augdawg09 at gmail.com
Tue Aug 24 18:44:17 CEST 2010


The other day, I wrote a little database just to fiddle around, but when I
try to run it it says that it has an unexpected indent. From what I can
tell, it doesn't. Here's the code. I'm using SPE.

database = []
datafile = open('/home/~/the-db/data')
for line in datafile:
database.append(line)

while tf2 != True:
command = raw_input("Enter a command. >> ")

while tf != True:
if "add" in command:
adder = raw_input("What to add? >> ")
data_base.append(adder)
if "no more" in adder:
tf = True

if "read" in command:
print(database)
 if "search" in command:
searcher = raw_input("Enter term to search >> ")
if searcher in database:
# Figure this out.
 if "exit database" in command:
print "Bye!"
sys.exit()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100824/bb6bae7a/attachment.html>


More information about the Tutor mailing list