Closed GataullinRR closed 2 years ago
Do not have experience Go enough to create Pull Request, but there is handmade Python script which will fix statements from sqlite dump file so that it could be imported into postgres:
import re
import os
with open ("/tmp/ctmp/grafana.sql", "r") as broken:
data=broken.read()
fixed = re.sub(r"(INSERT INTO .alert_configuration. VALUES.*?)([0])(\);.*)", r"\1FALSE\3", data)
fixed = re.sub(r"(INSERT INTO .alert_configuration. VALUES.*?)([1])(\);.*)", r"\1TRUE\3", fixed)
os.remove("/tmp/fixed.grafana.sql")
with open("/tmp/fixed.grafana.sql", "w") as fixed_file:
fixed_file.write(fixed)
import re
import os
with open ("./unfix.grafana.sql", "r") as broken:
data=broken.read()
fixed = re.sub(r"(INSERT INTO .alert_configuration. VALUES[\S\s]*?)(,[0])(\);)", r"\1,FALSE\3", data)
fixed = re.sub(r"(INSERT INTO .alert_configuration. VALUES[\S\s]*?)(,[1])(\);)", r"\1,TRUE\3", fixed)
with open("./grafana.sql", "w") as fixed_file:
fixed_file.write(fixed)
I also ran into this issue, this is my script in case the values span multi lines. We can use this script on the generated grafana.sql
, comment out all the generating grafana.sql
code in the main.go
and rebuild the docker image, put fixed grafana.sql in the correct place and run
@sandangel @GataullinRR thank you both for bringing this to my attention. I'm on paternity leave from my job currently and haven't been spending much time online as a result. Once I'm back to work, I'll pick this up and try to implement a fix.
Closed by #24
Grafana Version: 8.1.5 Output: