How can you connect to a postgresql database on heroku from google-colaboratory?

拥有回忆 提交于 2019-12-11 03:26:15

问题


Just started using colaboratory and would like to run sql queries against a postgresql db. Is this possible on colaboratory. I've used magic sql with jupyter nb to do this.


回答1:


It was a matter of using 2 %% instead of 1 that was giving me an error. What I'm running is this:

! pip install ipython-sql
! pip install psycopg2 
%sql postgres://<connect string>
%sql select tablename from pg_tables;

I saw an example where there sql was run with %%sql and when I tried that I got an error. Everything is running well now. Rebecca



来源:https://stackoverflow.com/questions/47216559/how-can-you-connect-to-a-postgresql-database-on-heroku-from-google-colaboratory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!