-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add SQL adapter #779
base: main
Are you sure you want to change the base?
add SQL adapter #779
Conversation
@@ -44,6 +44,9 @@ tiled = "tiled.commandline.main:main" | |||
|
|||
# This is the union of all optional dependencies. | |||
all = [ | |||
"adbc_driver_manager", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is used when tiled is installed like pip install "tiled[all]"
. These three should also be added to the section server
, below, so that they are included when tiled is installed like pip install "tiled[server]" # server only
.
e5858a1
to
8f676e8
Compare
Lifecycle:
|
add79c8
to
7679190
Compare
c0b88c6
to
baefdbf
Compare
Test script: import pandas
from tiled.client import from_uri
from tiled.structures.core import StructureFamily
from tiled.structures.data_source import Asset, DataSource, Management
from tiled.structures.table import TableStructure
client = from_uri("http://localhost:8000", api_key="secret")
df = pandas.DataFrame({"a": [1, 2, 3], "b": [1., 2., 3.]})
structure = TableStructure.from_pandas(df)
x = client.new(
structure_family=StructureFamily.table,
data_sources=[
DataSource(
management=Management.writable,
mimetype="application/x-tiled-sql-table",
structure_family=StructureFamily.table,
structure=structure,
assets=[],
),
],
metadata={},
specs=[],
key="x",
)
x.write(df)
x.append_partition(df, 0)
# This does not work yet
# x.read() # calls /table/partition/x?partition=0 adapter.read_partition() |
01a6f18
to
2befce1
Compare
8d26ce5
to
7913020
Compare
7913020
to
75b2ddc
Compare
For this PR
Intended usage now looks like... The following prompts the server to:
# This uploads no data.
x = client.create_appendable_table(schema, key="x") The following prompts the server to:
In a separate process, this would also work. We can access an existing table and keep appending. x = client["x"]
x.append_partition(df, 0) In following up PRs...
Maybe in the future partitions are added like this? Not sure whether PostgreSQL native "table partitioning" fits our use case.
def read_partition(self, partition):
query = f"SELECT * FROM {self.table_name} WHERE dataset_id={self.dataset_id} AND partition={partition}"
... |
preliminary start of sql adapter. to be continued ...
Checklist