0

I found this line to help configure Postgresql in web2py but I can't seem to find a good place where to put it :

db = DAL("postgres://myuser:mypassword@localhost:5432/mydb")

Do I really have to write it in all db.py ?

John Doe
  • 1,570
  • 3
  • 13
  • 22

2 Answers2

2

Files in the /models folder are executed in alphabetical order, so just put the DAL definition at the top of the first model file that needs to use it (it will then be available globally in all subsequent model files as well as all controllers and views).

Anthony
  • 25,466
  • 3
  • 28
  • 57
1

Actually, I found another way :

private/appconfig.ini

which does not prevent to define how you want it in db.py as :

db = DAL(myconf.take('db.uri'))

Thanks anyway ;)

John Doe
  • 1,570
  • 3
  • 13
  • 22