Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New version of Actual (24.9.0) broke actualpy #66

Closed
2 tasks done
tcpr1 opened this issue Sep 4, 2024 · 2 comments · Fixed by #65
Closed
2 tasks done

New version of Actual (24.9.0) broke actualpy #66

tcpr1 opened this issue Sep 4, 2024 · 2 comments · Fixed by #65
Labels
bug Something isn't working

Comments

@tcpr1
Copy link

tcpr1 commented Sep 4, 2024

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of actualpy.

Reproducible example

from actual import Actual
from actual.queries import get_transactions

with Actual(
    base_url=URL_ACTUAL, # Url of the Actual Server
    password=PASSWORD_ACTUAL, # Password for authentication
    encryption_password=ENCRYPTION_PASS_ACTUAL,    # Optional: Password for the file encryption. Will not use it if set to None.
    file=FILE_ACTUAL, # Set the file to work with. Can be either the file id or file name, if name is unique
    data_dir=DIR_ACTUAL, # Optional: Directory to store downloaded files. Will use a temporary if not provided
) as actual:
    transactions = get_transactions(actual.session)
    for t in transactions:
        account_name = t.account.name if t.account else None
        category = t.category.name if t.category else None
        print(t.date, account_name, t.notes, t.amount, category)

Log output

{
	"name": "IntegrityError",
	"message": "UNIQUE constraint failed: dashboard.id",
	"stack": "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mIntegrityError\u001b[0m                            Traceback (most recent call last)\nCell \u001b[1;32mIn[41], line 8\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mdatetime\u001b[39;00m\n\u001b[0;32m      6\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mactual\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mqueries\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m create_transaction, create_account\n\u001b[1;32m----> 8\u001b[0m \u001b[38;5;28;43;01mwith\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mActual\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbase_url\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mURL_ACTUAL\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpassword\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mPASSWORD_ACTUAL\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mfile\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mFILE_ACTUAL\u001b[49m\u001b[43m)\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mas\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43mactual\u001b[49m\u001b[43m:\u001b[49m\n\u001b[0;32m      9\u001b[0m \u001b[43m    \u001b[49m\u001b[38;5;66;43;03m# act = create_account(actual.session, \"My account\")\u001b[39;49;00m\n\u001b[0;32m     10\u001b[0m \u001b[43m    \u001b[49m\u001b[43mact\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mMy account\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\n\u001b[0;32m     11\u001b[0m \u001b[43m    \u001b[49m\u001b[43mt\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mcreate_transaction\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m     12\u001b[0m \u001b[43m        \u001b[49m\u001b[43mactual\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43msession\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m     13\u001b[0m \u001b[43m        \u001b[49m\u001b[43mdatetime\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdate\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtoday\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m     18\u001b[0m \u001b[43m        \u001b[49m\u001b[43mamount\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdecimal\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mDecimal\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m10.05\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m     19\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\nFile \u001b[1;32mc:\\git\\actualpy\\.conda\\Lib\\site-packages\\actual\\__init__.py:92\u001b[0m, in \u001b[0;36mActual.__enter__\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m     90\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_in_context \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[0;32m     91\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_file:\n\u001b[1;32m---> 92\u001b[0m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdownload_budget\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_encryption_password\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m     93\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\n\nFile \u001b[1;32mc:\\git\\actualpy\\.conda\\Lib\\site-packages\\actual\\__init__.py:328\u001b[0m, in \u001b[0;36mActual.download_budget\u001b[1;34m(self, encryption_password)\u001b[0m\n\u001b[0;32m    326\u001b[0m \u001b[38;5;66;03m# run migrations if needed\u001b[39;00m\n\u001b[0;32m    327\u001b[0m migration_files \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdata_file_index()\n\u001b[1;32m--> 328\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun_migrations\u001b[49m\u001b[43m(\u001b[49m\u001b[43mmigration_files\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m:\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    329\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msync()\n\u001b[0;32m    330\u001b[0m \u001b[38;5;66;03m# create session if not existing\u001b[39;00m\n\nFile \u001b[1;32mc:\\git\\actualpy\\.conda\\Lib\\site-packages\\actual\\__init__.py:144\u001b[0m, in \u001b[0;36mActual.run_migrations\u001b[1;34m(self, migration_files)\u001b[0m\n\u001b[0;32m    142\u001b[0m         exec_entries \u001b[38;5;241m=\u001b[39m re\u001b[38;5;241m.\u001b[39mfindall(\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdb\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124m.execQuery\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124m(`([^`]*)`\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m\"\u001b[39m, sql_statements, re\u001b[38;5;241m.\u001b[39mDOTALL)\n\u001b[0;32m    143\u001b[0m         sql_statements \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(exec_entries)\n\u001b[1;32m--> 144\u001b[0m     conn\u001b[38;5;241m.\u001b[39mexecutescript(sql_statements)\n\u001b[0;32m    145\u001b[0m     conn\u001b[38;5;241m.\u001b[39mexecute(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mINSERT INTO __migrations__ (id) VALUES (\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfile_id\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m);\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m    146\u001b[0m conn\u001b[38;5;241m.\u001b[39mcommit()\n\n\u001b[1;31mIntegrityError\u001b[0m: UNIQUE constraint failed: dashboard.id"
}

Issue description

After upgrading Actual to version 24.9.0 the API does not connect anymore.

Expected behavior

Any basic usage example

Installed versions

  • actualpy version: 0.3.0 - Actual Server version: 24.9.0
@tcpr1 tcpr1 added the bug Something isn't working label Sep 4, 2024
@bvanelli
Copy link
Owner

bvanelli commented Sep 5, 2024

Hello,

Thanks for the report, I'm aware of the breaking changes, it was caused because Actual changed their way of handling migrations (js files instead of sql files).

I did some improvements in #65 and intend to merge that and generate a new release still today.

@bvanelli
Copy link
Owner

bvanelli commented Sep 5, 2024

@tcpr1 a new version was released, let me know if you still face problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants