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 trialjaesonshin
Python Development Techdegree Graduate 9,939 PointsBase.metadata.create_all(engine)
would this work to create just the users table?
User.metadata.create_all(engine)
if not, how would I do that?
Best,
Jaeson
1 Answer
Chris Freeman
Treehouse Moderator 68,441 PointsHey jaesonshin, good question! According to the create_all docs, the parameter tables
may list the tables to create. Default is None
where all would be created.
Try Base.metadata.create_all(tables=[User])
Doc entry:
sqlalchemy.schema.MetaData.create_all(bind=None, tables=None, checkfirst=True)
Create all tables stored in this metadata.
Conditional by default, will not attempt to recreate tables already present in the target database.
Parameters
bind β A Connectable used to access the database; if None, uses the existing bind on this MetaData, if any.
tables β Optional list of Table objects, which is a subset of the total tables in the MetaData (others are ignored).
checkfirst β Defaults to True, donβt issue CREATEs for tables already present in the target database.
jaesonshin
Python Development Techdegree Graduate 9,939 Pointsjaesonshin
Python Development Techdegree Graduate 9,939 PointsOh.. I should have read the documentation more carefully... Thanks for putting up with this :)