PyDBML
PyDBML copied to clipboard
Add load(s) and dump(s) methods
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:
dumpwrites a filedumpsreturns a stringloadparses a fileloadsparses 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))