Skip to content

Instantly share code, notes, and snippets.

@Ramko9999
Created June 23, 2020 22:00
Show Gist options
  • Save Ramko9999/ad6970ed04b3c3010ae940d7b93b9e09 to your computer and use it in GitHub Desktop.
Save Ramko9999/ad6970ed04b3c3010ae940d7b93b9e09 to your computer and use it in GitHub Desktop.
import os
TXT_PATH = ""
QUERY_PATH = ""
text = ""
queries = []
with open(TXT_PATH, "r") as f:
text = f.read().strip()
queries = list(map(lambda x: x.strip(), text.split("CREATE QUERY")))
queries = queries[1:]
os.chdir(QUERY_PATH)
for query in queries:
j = query.index("(")
name = query[:j].strip()
query = f"DROP QUERY {name} \n CREATE " + query + f" \n INSTALL QUERY {name}"
with open(f'{name}.gsql', "w") as f:
f.write(query)
print(name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment