get_db tries to get a postgres database. If it does not found one, it thinks it running local and revers to sqlite.
On Monday, 3 December 2012 11:10:32 UTC-6, Niphlod wrote: > > db = DAL('sqlite://heroku.test.sqlite') > > isn't this problem related to the fact that trying to use a sqlite db on > heroku is forbidden ? (read-only filesystem!) > > On Monday, December 3, 2012 6:00:26 PM UTC+1, Massimo Di Pierro wrote: >> >> Can you try run this: >> >> heroku addons:add heroku-postgresql:dev >> >> On Sunday, 2 December 2012 08:41:53 UTC-6, Joe Repka wrote: >>> >>> I tested with the welcome app. The script seems to work fine now. Web2py >>> on Heroku opens in a browser after the script runs. >>> >>> However, there is still a database driver error: >>> <type 'exceptions.RuntimeError'> Failure to connect, tried 5 times: >>> Traceback (most recent call last): File "/app/gluon/dal.py", line 6825, in >>> __init__ self._adapter = ADAPTERS[self._dbname](**kwargs) File >>> "/app/gluon/dal.py", line 2094, in __init__ if do_connect: >>> self.find_driver(adapter_args) File "/app/gluon/dal.py", line 709, in >>> find_driver raise RuntimeError("no driver available %s" % >>> str(self.drivers)) RuntimeError: no driver available ('sqlite2', 'sqlite3') >>> >>> 1. >>> 2. >>> 3. >>> 4. >>> 5. >>> 6. >>> 7. >>> 8. >>> 9. >>> 10. >>> 11. >>> 12. >>> 13. >>> 14. >>> 15. >>> 16. >>> 17. >>> 18. >>> 19. >>> 20. >>> >>> Traceback (most recent call last): >>> File "/app/gluon/restricted.py", line 212, in restricted >>> exec ccode in environment >>> File "/app/applications/welcome/models/db.py" >>> <https://obscure-springs-6909.herokuapp.com/admin/default/edit/welcome/models/db.py>, >>> line 15, in <module> >>> db = get_db() >>> File "/app/gluon/contrib/heroku.py", line 28, in get_db >>> db = DAL('sqlite://heroku.test.sqlite') >>> File "/app/gluon/dal.py", line 6844, in __init__ >>> raise RuntimeError("Failure to connect, tried %d times:\n%s" % >>> (attempts, tb)) >>> RuntimeError: Failure to connect, tried 5 times: >>> Traceback (most recent call last): >>> File "/app/gluon/dal.py", line 6825, in __init__ >>> self._adapter = ADAPTERS[self._dbname](**kwargs) >>> File "/app/gluon/dal.py", line 2094, in __init__ >>> if do_connect: self.find_driver(adapter_args) >>> File "/app/gluon/dal.py", line 709, in find_driver >>> raise RuntimeError("no driver available %s" % str(self.drivers)) >>> RuntimeError: no driver available ('sqlite2', 'sqlite3') >>> >>> >>> On Friday, November 30, 2012 6:34:15 AM UTC-8, Massimo Di Pierro wrote: >>>> >>>> You are right. There is a type in the script. I just fixed it in trunk. >>>> The second issue is a bug in dal.py. I also just fixed that. Please check >>>> again and let us know. >>>> >>>> On Thursday, 29 November 2012 14:46:40 UTC-6, Joe Repka wrote: >>>>> >>>>> pip install is not finding postgresql2 for me: >>>>> >>>>> "Could not find any downloads that satisfy the requirement postgresql2 >>>>> No distributions at all found for postgresql2" >>>>> >>>>> I tried installing psycopg2 instead, but no love from that: >>>>> >>>>> "<type 'exceptions.RuntimeError'> Failure to connect, tried 5 times: >>>>> Traceback (most recent call last): File "/app/gluon/dal.py", line 6825, >>>>> in >>>>> __init__ self._adapter = ADAPTERS[self._dbname](**kwargs) File >>>>> "/app/gluon/dal.py", line 2094, in __init__ if do_connect: >>>>> self.find_driver(adapter_args) File "/app/gluon/dal.py", line 709, in >>>>> find_driver raise RuntimeError("no driver available %s" % self.drivers) >>>>> TypeError: not all arguments converted during string formatting >>>>> " >>>>> >>>>> >>>>> On Thursday, November 29, 2012 7:41:45 AM UTC-8, Massimo Di Pierro >>>>> wrote: >>>>>> >>>>>> FYI (from web2py-developers) >>>>>> >>>>>> >>>>>> Hello everybody, >>>>>> >>>>>> At PyCon Argentina I met Craig Kerstiens from Heroku. He explained to >>>>>> me how heroku works and we were able to make web2py work on heroku. >>>>>> >>>>>> This is still experimental and I will continue tweak it but you may >>>>>> want to give it a try and share your suggestions for improvement: >>>>>> >>>>>> >>>>>> HOWTO: >>>>>> >>>>>> 1) get a heroku account and SDK (it is all free) >>>>>> >>>>>> 2) download web2py from google code (not from github because you do >>>>>> not want the .git folder) >>>>>> >>>>>> hg clone https://massimo.dipie...@code.google.com/p/web2py/ >>>>>> >>>>>> cd web2py >>>>>> >>>>>> 3) install your web2py apps >>>>>> >>>>>> 4) in each app, replace >>>>>> >>>>>> db=DAL(…) >>>>>> >>>>>> with >>>>>> >>>>>> from gluon.contrib.heroku import get_db >>>>>> >>>>>> >>>>>> db = get_db() >>>>>> >>>>>> 5) from inside the web2py folder do (this create a git repo, if you >>>>>> have one, delete it): >>>>>> >>>>>> scripts/setup-web2py-heroku.sh >>>>>> >>>>>> Now should have your apps running on heroku with postgresql. >>>>>> >>>>>> caveats: >>>>>> >>>>>> get_db() gives you a postgresql connection on heroku and stores >>>>>> sessions, migrations , and uploads in postgres (one db for all apps). >>>>>> When >>>>>> running locally uses a heroku.test.sqlite database (one for each app). I >>>>>> will post instructions so that each app gets its own database. Tickets >>>>>> still go in file system and will be accessible via admin interface but >>>>>> every 24hrs the file system is wiped out and tickets are lost. >>>>>> >>>>>> Admin is not in readonly mode but any change you do via admin will be >>>>>> lost when the system is reset (every 24 hrs). So you should assume it is >>>>>> readonly. >>>>>> >>>>>> Appadmin works fine. >>>>>> >>>>>> Is the DAL(…) -> get_db() replacement too much to ask to the users? >>>>>> We could do it automatically under the hood once we detect heroku. What >>>>>> do >>>>>> you think? Using get_db gives more flexibility for tweaking, >>>>>> specifically >>>>>> when multiple databases are present. >>>>>> >>>>>> There are two files that need to be created (done by >>>>>> setup-web2py-heroku.sh): requirements.txt and Procfile. We could ship >>>>>> them >>>>>> with web2py but people need to be able to configure them anyway. Should >>>>>> we >>>>>> ship them or let users create them? >>>>>> >>>>>> This should be even easier. People should be able to simply git >>>>>> commit apps (with get_db) and pip install web2py. I do not know how to >>>>>> do >>>>>> it because I do not understand distutil and git well enough yet. Perhaps >>>>>> people should be able to git pull apps directly from the admin running >>>>>> on >>>>>> heroku. >>>>>> >>>>>> >>>>>> Massimo >>>>>> >>>>> --