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 trialTim Balzer
13,315 PointsWhy 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",
host="host",
port="port",
user="username",
password="password")
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?
3 Answers
Tim Balzer
13,315 PointsUnfortunately, PostgreSQL will not allow you to create the database. Instead, you will need to create the database ahead of time.
Kenneth Love
Treehouse Guest TeacherYeah, I think SQLite is the only database engine that doesn't require the database to exist beforehand.
Randolph Judy
Courses Plus Student 28,198 PointsI 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.