当我跑
heroku run python
>>> from app.main import app
>>> app.config['SQLALCHEMY_DATABASE_URI']
'postgres://<url string>' # the database url is passed correctly
>>> from app.main import db
>>> db.create_all()
Run Code Online (Sandbox Code Playgroud)
它给出了这个错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1039, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 1031, in _execute_for_all_tables
op(bind=self.get_engine(app, bind), **extra)
File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 962, in get_engine
return connector.get_engine()
File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line 556, in get_engine
self._engine = rv = self._sa.create_engine(sa_url, options)
File "/app/.heroku/python/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py", line …Run Code Online (Sandbox Code Playgroud) 在这一点上,经过大量研究和谷歌搜索,我了解了主要和渲染器的作用,以及它们在 Electron 应用程序中的重要性。
但是,在这里我发出请求,希望得到所有知识渊博的人的回答:请我能清楚地说明如何在我的应用程序中实现这一点吗?
我有一个 main.js、index.html 和 style.css,我正在尝试从 html 文件中触发一个 javascript 函数。@Manprit Singh Sahota 有同样的问题,Electron js 中的按钮单击事件绑定,并解决了它(幸运的是他),但只是说明他正在 renderer.js 中设置他的函数,而没有解释在哪里、什么和如何。@NealR也有类似的问题,但也没有解释他如何关联他的 renderer.js。
请有人揭开这个神秘文件保存在哪里的秘密,以及我如何在我的程序中引用它?
不要建议电子文档,我已经通过它,它似乎需要一些严重的改进......
主文件
const electron = require('electron');
const { app, BrowserWindow } = require('electron');
//stuff creating window...
function applyFormattingRules() {
console.log('called!');
};
//more stuff opening and closing window...
Run Code Online (Sandbox Code Playgroud)
索引.html
<head>
//...
<script src="main.js"></script>
</head>
<body>
//...
<button type="button" class="btn btn-secondary" name="applyRules"
onclick="applyFormattingRules()">Apply formatting</button>
</body>
Run Code Online (Sandbox Code Playgroud)
我的窗口工作正常,没有错误。但是当我单击按钮时,什么也没有发生,也没有任何日志记录到控制台。也许我在代码中做错了什么,但我所有的研究似乎都指向 Electron 主进程和渲染器进程。
任何建议非常感谢。
我用来flask-sqlalchemy更新mssql记录,但它返回-1。
库版本:
代码第 1 部分:
ret = db.session.query(XXX).filter_by(id=1).update({"xxx": "xxxx"})
print("ret", ret)
db.session.commit()
Run Code Online (Sandbox Code Playgroud)
为ret-1,但记录已被修改。
代码第 2 部分:
obj = XXX.query.filter_by(id=q).first()
obj .xx = "xxx"
db.session.commit()
Run Code Online (Sandbox Code Playgroud)
引发错误:
sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'XXX' expected to update 1 row(s); -1 were matched.
Run Code Online (Sandbox Code Playgroud)
而且修改没有成功。
sqlalchemy ×2
electron ×1
flask ×1
heroku ×1
javascript ×1
node.js ×1
postgresql ×1
python ×1
renderer ×1
rowcount ×1
sql-server ×1