Flask创建数据库-出现问题

使用flask创建SQLite数据库出现问题:

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: novels [SQL: 'SELECT novels.id AS novels_id, novels.book_name AS novels_book_name, novels.book_url AS novels_book_url, novels.book_img AS novels_book_img, novels.author AS novels_author, novels.style AS novels_style, novels.last_update AS novels_last_update, novels.profile AS novels_profile, novels.search_name AS novels_search_name, novels.page AS novels_page \nFROM novels \nWHERE novels.search_name = ? AND novels.page = ?'] [parameters: ('诛仙', 0)]

原来是数据库没有创建,路径不对,正确路径:

SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or 'sqlite:///' + os.path.join(basedir, 'data-dev.sqlite')

注意,是 SQLALCHEMY_DATABASE_URI
而我写成了 SQLALCHEMY_DATABASE_URL,
一字之差,害死人啊~~~

你可能感兴趣的:(Flask创建数据库-出现问题)