【问题标题】:How can you connect to a postgresql database on heroku from google-colaboratory?如何从 google-colaboratory 连接到 heroku 上的 postgresql 数据库?
【发布时间】:2018-04-23 07:34:19
【问题描述】:

刚开始使用 colaboratory,想对 postgresql 数据库运行 sql 查询。这在colaboratory上是否可行。我用 jupyter nb 的魔法 sql 来做到这一点。

【问题讨论】:

  • 原则上,任何 Jupyter notebook 都应该在 Colab 中工作。你有失败的样本吗?出了什么问题?

标签: google-colaboratory


【解决方案1】:

这是一个使用 2 %% 而不是 1 的问题,这给了我一个错误。我正在运行的是:

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

我看到了一个使用 %%sql 运行 sql 的示例,当我尝试时出现错误。 现在一切都运行良好。 丽贝卡

【讨论】:

    猜你喜欢
    • 2021-09-30
    • 2014-09-25
    • 2014-03-04
    • 1970-01-01
    • 2020-07-16
    • 2019-05-31
    • 2014-03-30
    • 2013-04-19
    • 2013-10-07
    相关资源
    最近更新 更多