db.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # -*- coding: utf-8 -*-
  2. #########################################################################
  3. ## This scaffolding model makes your app work on Google App Engine too
  4. ## File is released under public domain and you can use without limitations
  5. #########################################################################
  6. ## if SSL/HTTPS is properly configured and you want all HTTP requests to
  7. ## be redirected to HTTPS, uncomment the line below:
  8. # request.requires_https()
  9. ## app configuration made easy. Look inside private/appconfig.ini
  10. from gluon.contrib.appconfig import AppConfig
  11. ## once in production, remove reload=True to gain full speed
  12. myconf = AppConfig(reload=True)
  13. DATABASE = None
  14. DATABASE_URI = "mysql://benchmarkdbuser:[email protected]:3306/hello_world"
  15. db = DAL(DATABASE_URI, fake_migrate_all=True)
  16. DATABASE = db
  17. ## store sessions and tickets there
  18. ##session.connect(request, response, db=db)
  19. ## or store session in Memcache, Redis, etc.
  20. ## from gluon.contrib.memdb import MEMDB
  21. ## from google.appengine.api.memcache import Client
  22. ## session.connect(request, response, db = MEMDB(Client()))
  23. ## by default give a view/generic.extension to all actions from localhost
  24. ## none otherwise. a pattern can be 'controller/function.extension'
  25. response.generic_patterns = []
  26. db.define_table("world",
  27. Field("id"),
  28. Field("randomNumber")
  29. )
  30. db.define_table("fortune",
  31. Field("id"),
  32. Field("message")
  33. )