当前位置:网站首页>Create database table db.create in flask project_ all()
Create database table db.create in flask project_ all()
2022-07-24 00:58:00 【Sindweller5530】
Flask The project needs to be deployed according to database Create data tables by using the model classes defined in . Directly in database.py Write in db.create_all() It doesn't work , Report errors :
...
from app import db, logger
ModuleNotFoundError: No module named 'app'
to update : Need to be in py Add... To the document
import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
So you can find the path Search for a long time without success in a separate file (database.py) In the implementation of db.create_all(), So first __init__.py Write the created statement , Be careful to write it at the end import database It only works after .
from flask import Flask
from config import Config
from flask_sqlalchemy import SQLAlchemy
app = Flask(__name__)
app.config.from_object(Config)
db = SQLAlchemy(app)
from app import database
db.create_all()
Comment this out after creating it .
边栏推荐
- 爬虫requests模块的基本使用
- Sparksql design and introduction, 220722,
- There are various signs that apple is expected to support AV1
- Tutorial on the principle and application of database system (046) -- MySQL query (VIII): group by
- Introduction to several scenarios involving programming operation of Excel in SAP implementation project
- What is the function of the select... For UPDATE statement? Can you lock tables or rows?
- Dark horse programmer - interface test - four day learning interface test - day 4 - postman reads external data files, reads data files, IHRM project practice, employee management module, adds employe
- JS determines whether the element scrolls to the top
- This is a big problem
- Graphic pipeline (I) post-processing stage alpha test template test depth test mix
猜你喜欢

How to speed up matrix multiplication -- optimizing GEMM (CPU single thread)

Image processing: Generation 3 × Window of 3

Case error of MySQL branch statement

Dynamic rip configuration

T-seda code

工作3年的测试员跳槽后工资是原来的2倍,秘诀原来是......

Small farmers also have big goals in the test, and the latest big bat interview summary (constantly updating...)

创建自签名证书, 对exe文件进行数字签名

Programmeur de cheval noir - test d'interface - test d'interface d'apprentissage de quatre jours - jour 4 - Postman lit des fichiers de données externes, lit des données de fichiers de données, IHRM P

爬虫requests模块的基本使用
随机推荐
Leetcode set the intersection size to at least 2
Idea hot deployment (hot load)
How to troubleshoot the problem that VPN server cannot forward
Seektiger's okaleido has a big move. Will the STI of ecological pass break out?
深入理解协程
黑馬程序員-接口測試-四天學習接口測試-第四天-Postman讀取外部數據文件,讀取數據文件數據,iHRM項目實戰,員工管理模塊,添加員工,批量運行測試用例,生成測試報告,
[QNX hypervisor 2.2 user manual]9 VM configuration reference
An article teaches you the basic use of kubernetes
Fpga:ov7725 camera displays images in rgb565 format through vga/hdmi
Database connection pool & dbutils
Dark horse programmer - interface test - four day learning interface test - day 4 - postman reads external data files, reads data files, IHRM project practice, employee management module, adds employe
Tutorial on principles and applications of database system (051) -- MySQL query (XIII): using queries in DML statements
Tutorial on principles and applications of database system (039) -- MySQL query (I): syntax analysis of select command
IDEA 热部署(热加载)
Bean Validation自定义容器验证篇----06
WinVerifyTrust调用返回80096005错误,时间戳签名或证书无法验证或已损坏
Redis common commands
JS drag and drop element
Programmeur de cheval noir - test d'interface - test d'interface d'apprentissage de quatre jours - jour 4 - Postman lit des fichiers de données externes, lit des données de fichiers de données, IHRM P
Dynamic rip configuration