Skip to content

Instantly share code, notes, and snippets.

@pierew
Created August 17, 2022 21:26
Show Gist options
  • Save pierew/8bdb0ae2cf2fc7e4de00d39a88c7dc0f to your computer and use it in GitHub Desktop.
Save pierew/8bdb0ae2cf2fc7e4de00d39a88c7dc0f to your computer and use it in GitHub Desktop.
recover-nextcloud-vcards
db = pymysql.connect(host="localhost",user="root",password="****",database="nextcloud",cursorclass=pymysql.cursors.DictCursor)
with db:
with db.cursor() as cursor:
sql = "SELECT carddata,uri FROM oc_cards WHERE addressbookid='5';"
cursor.execute(sql)
result = cursor.fetchall()
for item in result:
vcard = open("/tmp/restored_vcards/"+item["uri"],"w")
vcard.write(item["carddata"].decode("utf-8"))
vcard.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment