Skip to content
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

Make CrateDB work with dataset #48

Open
amotl opened this issue Oct 6, 2022 · 1 comment
Open

Make CrateDB work with dataset #48

amotl opened this issue Oct 6, 2022 · 1 comment
Labels
meta A meta issue pitch A pitch for adding a new integration item, after evaluating it, and writing a tutorial

Comments

@amotl
Copy link
Member

amotl commented Oct 6, 2022

Hi there,

back in a while, I've tried to use the sweet dataset package with CrateDB.

Being built on top of SQLAlchemy, dataset works with all major databases, such as SQLite, PostgreSQL and MySQL.

For exercising it, and to provide a common ground for others to experiment with, I've created the cratedb-dataset-demo.py gist.

Within this meta issue, all related issues will be tracked which are needed to make the demo program work completely.

With kind regards,
Andreas.

References

@amotl amotl added the meta A meta issue label Oct 6, 2022
@amotl
Copy link
Member Author

amotl commented Oct 6, 2022

With recent improvements, most notably crate/crate#11165, which added the gen_random_text_uuid() scalar function, primary key values can be automatically generated when inserting new records. This was essential to make INSERT operations work like table.insert(dict(name="John Doe", age=37)).

The corresponding SQL DDL statement looks like:

CREATE TABLE IF NOT EXISTS "doc"."testdrive" (
    "id" TEXT DEFAULT gen_random_text_uuid() NOT NULL,
    "name" TEXT,
    "age" INTEGER,
    "gender" TEXT,
    PRIMARY KEY ("id")
);

Currently, the schema has to be provided manually, maybe because dataset itself only handles automatic provisioning of autoincrement-like columns, i.e. one of Types.integer, Types.bigint 12. It would be a nice-to-have to make the automatic schema creation work, like it works on other databases as well. Maybe it will be enough to add Types.{string,text} at 2?

One of the main features of dataset is to automatically create tables and columns as data is inserted. This behaviour can optionally be disabled via the ensure_schema argument. It can also be overridden in a lot of the data manipulation methods using the ensure flag.

-- https://dataset.readthedocs.io/en/latest/api.html#connecting

Footnotes

  1. https://github.com/pudo/dataset/blob/1.5.2/dataset/table.py#L338-L343

  2. https://github.com/pudo/dataset/blob/1.5.2/dataset/table.py#L48 2

@amotl amotl transferred this issue from crate/crate-python Sep 6, 2023
@amotl amotl changed the title [META] Make CrateDB work with dataset Make CrateDB work with dataset Sep 6, 2023
@amotl amotl added the pitch A pitch for adding a new integration item, after evaluating it, and writing a tutorial label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta A meta issue pitch A pitch for adding a new integration item, after evaluating it, and writing a tutorial
Projects
None yet
Development

No branches or pull requests

1 participant