Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Anthony Grodowski
4,902 Pointssafe=True
What excatly that means? It's connected with my concern about that chunk of code:
def initialize():
"""Create the database and the table if they don't exist"""
db.connect()
db.create_tables([Entry], safe=True)
How does python know that this shouldn't be done while the database already exists? I'm guessing that it has something to do with safety=True but idk how and why. Also what's the difference between database and the table? Isn't the database a table itself?
1 Answer
KRIS NIKOLAISEN
54,974 PointsI had to go to the peewee docs to verify this but safe is a parameter to specify whether or not to use the IF NOT EXISTS clause. If set to true then the table will only be created if it doesn't already exist.
What a database is depends on the type of database you are referring to. A database can contain one or more tables. It may also contain views, stored procedures, forms, reports, among other things. A table is a single element within a database and is used to store data.