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

Ingest SQLDelight schemas #19

Closed
julioz opened this issue May 16, 2020 · 5 comments
Closed

Ingest SQLDelight schemas #19

julioz opened this issue May 16, 2020 · 5 comments
Labels
Consumer Work related to one of the input consumers enhancement New feature or request

Comments

@julioz
Copy link
Owner

julioz commented May 16, 2020

Besides Room, another popular library used in the Android ecosystem is SQLDelight. If we can generate schemas (or parse the .sq files) to use as input for generating DBML, we can increase the applicability of FloorPlan.

@julioz julioz added enhancement New feature or request help wanted labels May 16, 2020
@julioz
Copy link
Owner Author

julioz commented May 18, 2020

It seems like there is a generateSchema gradle task we could use to export the DB schema.

I still haven't had the time to give it a try to see what the output looks like.

julioz added a commit that referenced this issue May 20, 2020
- The `:floorplan-cli` module now depends directly on `:room-consumer`, but the goal is that eventually that becomes ['consumer-agnostic'](#19).

- There is a new `:dbml` module that is home for the DBML representations in Kotlin. This means parsing from DBML (in case of `:dbml-parser`) or as output (in case of `:room-consumer`) will share the same modeling representation, allowing for proper mapping.
@julioz julioz added the Consumer Work related to one of the input consumers label Jun 4, 2020
@julioz
Copy link
Owner Author

julioz commented Jun 17, 2020

Ran into a few small open source projects using SQLDelight:

After a few changes to specify a sqldelight block in their gradle script configuration, I was able to export SQLite .db files containing the database schema. Next step is understand how we can transform that into input for a FloorPlan Consumer... maybe sqlite-jdbc or would that be overkill?

@joreilly
Copy link

joreilly commented Jun 17, 2020

I should add that the galway-bus-android is probably a bit out of date....need to grab some time at some point to update it (across a number of different areas).

A more up to date one that also uses SQLDelight is https://github.com/joreilly/PeopleInSpace (though is very basic)

@julioz
Copy link
Owner Author

julioz commented Jun 19, 2020

So, given SQLDelight exports the .db files which aren't specific to Android, but to SQLite, it makes sense to build a SQLiteConsumer that connects to these DBs, pulls out schemas mapping them as input to FloorPlan's pipeline.

I have found a more complex sample SQLite Schema that can also be used for testing.

julioz added a commit that referenced this issue Jun 26, 2020
SQLDelight is a popular multiplatform ORM that is able to expose its schemas via a Gradle task. On #19, we discuss the possibility of ingesting them to generate ER diagrams similarly to how we do for Android's Room.

Interestingly, they export `.db` files, standard SQLite database definitions, that can be connected to and queried. Here, we rely heavily on the `PRAGMA` functions to introspect into the database schema and pull out the interesting properties to build our `DBML` memory model.

This PR, then, wires up the new `SqliteConsumer`  (with the help of a input file format sniffer heuristic) to allow not only for integration between FloorPlan and SQLDelight, but with every other ORM that can expose `.db` files (potentially even [iOS' CoreData](https://stackoverflow.com/a/15119886/12511149)).
@julioz
Copy link
Owner Author

julioz commented Jun 26, 2020

After #40, we can ingest SQLite .db files, which are also the output of SQLDelight through the schemas task.
Here we see an example PNG output with @joreilly's PeopleInSpace project after a few small gradle script changes:

1

Will be released as part of FloorPlan-0.2 👍

@julioz julioz closed this as completed Jun 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Consumer Work related to one of the input consumers enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants