Created
May 15, 2023 22:25
-
-
Save msullivan/b7f0f970f9c8535354266391ff0c888d to your computer and use it in GitHub Desktop.
script for quickly iterating on extension packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import edgedb | |
import sys | |
EXT = 'ltree' | |
def main(argv): | |
db = edgedb.create_client( | |
port=5656, database='edgedb', tls_security='insecure' | |
) | |
# Delete the extension and the package if it already exists | |
ext = db.query(f''' | |
select schema::Extension filter .name = '{EXT}'; | |
''') | |
if ext: | |
db.execute(f''' | |
drop extension {EXT}; | |
''') | |
ext_package = db.query(f''' | |
select sys::ExtensionPackage filter .name = '{EXT}'; | |
''') | |
if ext_package: | |
db.execute(f''' | |
drop extension package {EXT} VERSION '1.0'; | |
''') | |
# Run the script; should create the package | |
with open(argv[1]) as f: | |
db.execute(f.read()) | |
# Create the extension | |
db.execute(f''' | |
create extension {EXT}; | |
''') | |
if __name__ == '__main__': | |
main(sys.argv) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment