Jupyter中用SQL (dcamp的project)

首先
%%sql postgresql:///countries
然后
select xxx;

And after the first connection to the database, the connection code (postgresql:///countries) can be omitted. the single % this time.
%SQL select xxx (%和SQL之间没有空隙 SQL和select要写在同一排)
更多的差别见documentation
(https://github.com/catherinedevlin/ipython-sql#pandas)

We can even convert our SQL results to a pandas DataFrame! Let's convert the entire countries table.

SQL Query

result = %sql SELECT * FROM countries;

To pandas DataFrame

df = result.DataFrame()
df.info()
先储存,再用.DataFrame() 功能变成df

SQLAlchemy也能在J里使用SQL

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容