Skip to content

Instantly share code, notes, and snippets.

@msullivan
Created May 15, 2023 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msullivan/b7f0f970f9c8535354266391ff0c888d to your computer and use it in GitHub Desktop.
Save msullivan/b7f0f970f9c8535354266391ff0c888d to your computer and use it in GitHub Desktop.
script for quickly iterating on extension packages
#!/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