Skip to content

Add load(s) and dump(s) methods#62

Open
samhaese wants to merge 150 commits intoVanderhoof:masterfrom
samhaese:feature/load-and-dump
Open

Add load(s) and dump(s) methods#62
samhaese wants to merge 150 commits intoVanderhoof:masterfrom
samhaese:feature/load-and-dump

Conversation

@samhaese
Copy link
Copy Markdown

@samhaese samhaese commented Apr 18, 2025

When I'm working with markup files in Python I usually use one of these packages:

I noticed that all of them have pretty much the same API:

  • dump writes a file
  • dumps returns a string
  • load parses a file
  • loads parses a string

I added that API to your package because it could make it easier for people to adopt it. I would understand if you rejected this change.

Example:

import pydbml

with open('test_file.dbml', 'r') as f:
    db = pydbml.load(f)

with open('test_save.dbml', 'w') as f:
    pydbml.dump(db)

s = """Table users {
    id integer
    user varchar
    role varchar
    created_at timestamp
}"""

db2 = pydbml.loads(s)

print(pydbml.dumps(db))

Vanderhoof and others added 29 commits August 11, 2024 09:19
- Integrated `prepare_text_for_dbml` into `default_to_str` for consistent handling of special characters in DBML column strings.
- Updated the test suite to include a new test case for handling binary string input (`b'0'`).
…default-escapse

Fix bug in DBML column default rendering with single quotes
…brackets

fix: line breaks in column and index options are allowed (Vanderhoof#48)
fix: quote tablegroup and project name on dbml render Vanderhoof#46
…_other_index_types

feat(indexes): support all Postgresql index types
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.

10 participants