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

Add support for SQLAlchemy as export format #399

Merged
merged 8 commits into from
Sep 4, 2024

Conversation

characat0
Copy link
Contributor

@characat0 characat0 commented Aug 30, 2024

Closes #398

Summary

In this PR I propose to add basic support for SQLAlchemy, we can discuss further details here.

My particular use case is focused on databricks sql connection, but I would be happy to receive feedback from people with other use cases

Description

Table names and comments are supported, as well as field comments. Table schema support is still limited to schema only, with support for fully qualified schemas (catalog.schema) on autogenerated migrations depending on sqlalchemy/alembic#1526.

Data Types

I've currently implemented support for the following primitive data types:

  • string: String with maxLength
  • text: String with maxLength
  • varchar: VARCHAR with maxLength
  • number, decimal, numeric: Numeric with precision and scale
  • int, integer: Integer
  • long, biting: BigInteger
  • float: Float
  • double: Double
  • boolean: Boolean
  • timestamp: TIMESTAMP
  • timestamp_tz: TIMESTAMP with tz=True
  • timestamp_ntz: TIMESTAMP_NTZ (only supported in databricks)
  • date: Date
  • bytes: LargeBinary with maxLength

I've also added support for arrays of these type of primitives.

  • Tests pass
  • ruff format
  • README.md updated (if relevant)
  •  CHANGELOG.md entry added

@jochenchrist
Copy link
Contributor

Thanks for this PR. I think, this is a very valuable contribution.

Please add a test case for this exporter.

@characat0
Copy link
Contributor Author

@jochenchrist thanks for the feedback, I've added some test cases inspired by the Pydantic export implementation

@jochenchrist
Copy link
Contributor

can you please also update the README and the CHANGELOG?

@jochenchrist jochenchrist merged commit 0d92247 into datacontract:main Sep 4, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for SQLAlchemy as export format
2 participants