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
Why does the script throw a fatal OperationalError when I try to create the database in PostgreSQL?
When attempting to create the database with my local instance of PostgreSQL, I had to make a few changes to the
db variable (since PostgreSQL doesn't like being passed .db files as database names):
db = PostgresqlDatabase("students",
Even after doing this, I am greeted with the following error:
peewee.OperationalError: FATAL: database "students" does not exist
How do I make the script create the database?
Unfortunately, PostgreSQL will not allow you to create the database. Instead, you will need to create the database ahead of time.
Kenneth LoveTreehouse Guest Teacher
Yeah, I think SQLite is the only database engine that doesn't require the database to exist beforehand.
Randolph JudyCourses Plus Student 28,198 Points
I had the same problem with MySQL and creating the Students Schema before running the script resolved this error. My code was the same except for using 'MySQLDatabase()'. I verified the table creation in the MySQL Workbench.