glaredb icon indicating copy to clipboard operation
glaredb copied to clipboard

Can I use glaredb with %%sql magic (jupyter notebook)? or SQLAlchemy?

Open RobinLin666 opened this issue 2 years ago • 2 comments

Description

I want to sql some delta tables in jupyter notebook without spark session. So, I found glaredb. So, can I use glaredb with %%sql magic?

RobinLin666 avatar Oct 26 '23 05:10 RobinLin666

Just wanted to clarify, are you specifically looking to be able to use %%sql in a notebook, or are you just looking for a way to glaredb in a notebook?

We have python bindings which we've tested in a variety of notebooks. You're able to install using:

!pip install glaredb

And then in another python cell, you can start using glaredb:

import glaredb

con = glaredb.connect()
con.sql("select 'hello'").show()

You can then use CREATE EXTERNAL TABLE (https://docs.glaredb.com/glaredb/sql-commands/create-external-table/#delta) or delta_scan (https://docs.glaredb.com/glaredb/sq-functions/delta_scan/) to read delta tables.

If you're looking specifically for running sql using %%sql, we would need look into that a bit more.

scsmithr avatar Oct 26 '23 17:10 scsmithr

Thank you for your reply! I want to use %%sql in a notebook. for example:

%%sql glaredb://xxx
select 'hello'

or

%%sql
SELECT * FROM 'https://huggingface.co/datasets/fka/awesome-chatgpt-prompts/raw/main/prompts.csv'

Since https://github.com/catherinedevlin/ipython-sql support %%sql feature, but only in sqlalchemy So, maybe we need a sqlalchemy dialects for glaredb.

RobinLin666 avatar Oct 27 '23 03:10 RobinLin666