[英]web2py database configuration
I found this line to help configure Postgresql in web2py but I can't seem to find a good place where to put it : 我发现这行代码可以帮助在web2py中配置Postgresql,但是我似乎找不到合适的放置位置:
db = DAL("postgres://myuser:mypassword@localhost:5432/mydb")
Do I really have to write it in all db.py ? 我真的必须在所有db.py中编写它吗?
/ models文件夹中的文件是按字母顺序执行的,因此只需将DAL
定义放在需要使用它的第一个模型文件的顶部(然后它将在所有后续模型文件以及所有控制器和视图中全局可用) )。
Actually, I found another way : 实际上,我发现了另一种方法:
private/appconfig.ini
which does not prevent to define how you want it in db.py as : 这不会阻止您在db.py中将其定义为:
db = DAL(myconf.take('db.uri'))
Thanks anyway ;) 不管怎么说,还是要谢谢你 ;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.