Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Why is my .db file not being created?
Why is my .db file not being created? I am using Flask SQLAlchemy, but I am having some problems. Here is my code:
from flask import Flask, render_template from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///test.db' db = SQLAlchemy(app)
It runs without error, but the .db file is not being created. Any ideas why?
Chris FreemanTreehouse Moderator 67,464 Points
You are almost there. From the quickstart document page it says:
To create the initial database, just import the db object from an interactive Python shell and run the SQLAlchemy.create_all() method to create the tables and database: >>> from yourapplication import db >>> db.create_all()
So if you above file is called myapp.py you would use: from myapp import db
db is the object you created in file
myapp.py, line 9.
Post back if you need more help. Good luck!!