Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

dataset: databases for lazy people #48

Closed
amotl opened this issue Oct 6, 2022 · 2 comments
Closed

dataset: databases for lazy people #48

amotl opened this issue Oct 6, 2022 · 2 comments
Labels
poke Something that has been poked into, but either failed or stalled

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
@amotl amotl added poke Something that has been poked into, but either failed or stalled and removed meta A meta issue pitch A pitch for adding a new integration item, after evaluating it, and writing a tutorial labels Dec 5, 2024
@amotl
Copy link
Member Author

amotl commented Dec 7, 2024

Hi again. The dataset library currently does not provide support for SQLAlchemy 2.x, yet. However, the sqlalchemy-cratedb package will not receive any improvements for SQLAlchemy 1.x any longer. We may revisit the library when it has gained corresponding support.

Instead, we exercised convenient DWIM-like database access in Python and Shell through the Records library and program now. Records is also powered by SQLAlchemy, and Tablib.

@amotl amotl changed the title Make CrateDB work with dataset dataset: databases for lazy people Dec 21, 2024
@crate crate locked and limited conversation to collaborators Dec 21, 2024
@amotl amotl converted this issue into discussion #208 Dec 21, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
poke Something that has been poked into, but either failed or stalled
Projects
None yet
Development

No branches or pull requests

1 participant