Created
June 12, 2023 09:16
-
-
Save ruanimal/caf29d8099a14f573579e1e99a1990d2 to your computer and use it in GitHub Desktop.
migrate config from medis to AnotherRedisDesktopManager
This file contains 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
import base64 | |
import os | |
import json | |
from sqlalchemy import create_engine | |
path = os.path.expanduser('~/Library/Containers/li.zihua.medis/Data/Library/Application Support/Medis/Local Storage/file__0.localstorage') | |
engine = create_engine(f'sqlite:///{path}') | |
res = engine.execute("select * from main.ItemTable where `key`='favorites'").fetchone() | |
res = dict(res) | |
old = json.loads(res['value']) | |
new = [] | |
for item in old: | |
if not item.get("host"): | |
print(f"skip {item!r}") | |
continue | |
new.append({ | |
"auth": item.get('password', ''), | |
"host": item["host"], | |
"key": item["key"], | |
"name": item["name"], | |
"port": item["port"], | |
}) | |
print(json.dumps(new, indent=4, ensure_ascii=False)) | |
with open('redis-conn.ano', 'wb') as fp: | |
fp.write(base64.b64encode(json.dumps(new).encode('utf8'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment