-
-
Save kkappel/65c6b83ee805cb936be0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| this snippet is used to load a web2py with postgresql environment | |
| you must install web2py (so gluon.*) from pyeggs : "pip install web2py" | |
| it will read your db.py models from the same directory | |
| ''' | |
| # web2py env | |
| from gluon.shell import exec_environment | |
| import psycopg2 | |
| from gluon import DAL, Field | |
| from gluon.template import render | |
| from gluon.dal import PostgreSQLAdapter | |
| if not (PostgreSQLAdapter.driver): PostgreSQLAdapter.driver = psycopg2 | |
| welcome = exec_environment('db.py') | |
| db = welcome.db | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment