TidierOrg / TidierDB.jl

Tidier database analysis in Julia, modeled after the dbplyr R package.
MIT License
46 stars 3 forks source link

Add example for how to connect to a local duckdb database #64

Closed kdheepak closed 1 month ago

kdheepak commented 1 month ago

I'm not able to figure out how to connect to an existing file:

image

I'm assuming this functionality exists but I don't see it in the documentation.

kdheepak commented 1 month ago

This works:

image

It requires the name of the file to end with .duckdb:

https://github.com/TidierOrg/TidierDB.jl/blob/d6651eb59f7123f122c29e0163a93444bf69a7ab/src/TidierDB.jl#L413-L421

Because my file ended with .duck.db, it tried to open an auth page on motherduck. imho, this UX can be improved.

drizk1 commented 1 month ago

Hey thanks for reaching out. It absolutely can be improved.

At this time, db_table doesnt directly support file paths to a database. it needs to be connected first.

drizk1 commented 1 month ago

I added a branch ("enhance-windowframe") you can try where connect should now support a .duck.db file

I will have to look into allowing db_table to support a database file, and i will definitely clarify the docs around it.

kdheepak commented 1 month ago

The docs have code like this:

path_or_name = "https://gist.githubusercontent.com/seankross/a412dfbd88b3db70b74b/raw/5f23f993cd87c283ce766e7ac6b329ee7cc2e1d1/mtcars.csv"

@chain DB.db_table(db, path_or_name) begin

Which made me think a local path would work but that doesn't appear to be the case.

drizk1 commented 1 month ago

Ahh yes I should clarify in the docs that only supports file paths no db paths

drizk1 commented 1 month ago

I have added example to the docs getting started page

Once this connection is established you can use show_tables(db) to view available tables in the database

Please reopen this issue or open any new issues if anything comes up.