Replies: 2 comments 2 replies
-
|
If I understand correctly, the |
Beta Was this translation helpful? Give feedback.
-
|
This is looking great! The table() and .sql() methods make sense and follow an expected pattern. Taking a step back, is it maybe a bit confusing to have a DataStore be acting as both a "session" and a "dataframe"? The user flow is simple enough imo, but the naming might be a bit confusing. This is more semantics here, but scoping the database/schema on a true Session object rather than a DataStore object is the more common pattern. We effectively achieve this with the above, just might be slightly confusing if there is not a specifically defined Session. Also, is there a close() method to kill the connection? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
chdb DataStore Remote Connection Design
Overview
Extend DataStore to support remote database connections with metadata discovery. No new classes or APIs - just make
databaseandtableparameters optional with smart error messages.User API
1. Create Connection-Level DataStore
Using
from_xxxfactory methods:Password masking in display:
2. Metadata Discovery
3. Select Database/Table
Using
use()to set defaults (mutable):Using
table()to create new DataStore (immutable):Why
table()instead ofds["..."]?Using
ds["..."]for table selection creates ambiguity with existing pandas-style operations:ds["column"]- select column (pandas behavior)ds[condition]- filter rows (pandas behavior)ds["db.table"]- select table (confusing!)The explicit
table()method eliminates this ambiguity:Key difference:
ds.use("db")self(for chaining)ds.table("db", "table")4. Execute SQL Queries
Table name resolution:
FROM production.usersuse()needed)FROM usersuse()FROM file('data.csv')5. Smart Error Messages
When table-level operations are called without specifying a table:
6. Complete Workflow Example
Parameter Reference
sourceclickhouse,mysql,postgresqlhosthost:9000)userpassworddatabaseuse()ortable()insteadtablesecureSupported Data Sources
databases()tables()describe()sql()Key Design Decisions
repr()/str()/ notebook displaysql()returns DataStore, execution deferred until neededds["column"]andds[condition]Beta Was this translation helpful? Give feedback.
All reactions