sqlite-diffable icon indicating copy to clipboard operation
sqlite-diffable copied to clipboard

`sqlite-diffable` callable as a library

Open PeskyPotato opened this issue 1 year ago • 1 comments

I've been using this package to build my website for a while and it's been absolutely great! I normally call the package through the CLI as intended but recently created callable function to consolidate the build into one Python script, which has been working so far.

Using the sample code from StackOverflow user Massimo Frasson, I built wrapper functions to call the load and dump click commands replicating all functionality as a proof of concept. These can be found on my fork under the py_module branch.

I've only done two commands as mentioned, and left object out as I don't use that. I think my error handling could also be better and I've not included any tests. I'm sharing this here in case it might help anyone else build or implement the same if it's of interest.

Example usage: Load replace defaults to False.

sqlite_diffable.load('posts.db', './content/posts/', replace=True)

Dump all defaults to False.

sqlite_diffable.dump('posts.db', './content/posts/', all=True)

tables can be set within an array.

sqlite_diffable.dump('posts.db', './content/posts/', tables=['tags', 'categories'])

PeskyPotato avatar May 04 '24 09:05 PeskyPotato

Added the objects function in commit: 8014dbea938ea0c1f540ec9599d58d09d186d849 Added simple tests in commit: 8865ebf9abac110144e5c2c02fdbca5cc339c7a7

PeskyPotato avatar May 04 '24 17:05 PeskyPotato