Skip to content

fix: check if the Article table exists#45

Merged
Helias merged 4 commits intoUNICT-DMI:mainfrom
Giuseppe-Tornello:test_2
Nov 7, 2025
Merged

fix: check if the Article table exists#45
Helias merged 4 commits intoUNICT-DMI:mainfrom
Giuseppe-Tornello:test_2

Conversation

@Giuseppe-Tornello
Copy link
Contributor

While following the Testing with Docker Compose I encountered an error in the log:

2025-11-06 23:57:58,726 - apscheduler.executors.default - INFO - Running job "scrape_news (trigger: interval[0:05:00], next run at: 2025-11-06 23:57:58 UTC)" (scheduled at 2025-11-06 23:57:58.724989+00:00)
2025-11-06 23:57:59,755 - telegram.ext.dispatcher - ERROR - No error handlers are registered, logging exception.
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/apscheduler/executors/base.py", line 125, in run_job
    retval = job.func(*job.args, **job.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ersubot/module/scraper/scraper.py", line 164, in scrape_news
    scrape_table(articles, context)
  File "/ersubot/module/scraper/scraper.py", line 113, in scrape_table
    db_cursor.execute(db_fetch)
sqlite3.OperationalError: no such table: Articles

even though I tried renaming the .db.dist database to .db I kept getting the same error
I also tried adding another -v parameter as in the Docker-compose file but I kept getting the same error

So i came up with this solution in order to check the Article table existance.
Since the code is already checking for the existance of UserSettings and News tables, I decided to put setup_articles function inside of setup_db() because it is related to that. I also decided to put setup_articles() inside of scraper.py for the same reason.

@Helias
Copy link
Member

Helias commented Nov 7, 2025

Stupid questions:
Did you double check the path? Are you using an absolute path for the docker compose volume?

Did you open manually with sqlitebrowser the .db file first? If it works manually then you could use docker compose down -v and docker compose up again.

@Helias
Copy link
Member

Helias commented Nov 7, 2025

I saw the issue, nice catch, the idea is to keep updated the sql structure in the .dist file, we should do it sooner or later

@Helias Helias merged commit c83cebb into UNICT-DMI:main Nov 7, 2025
0 of 6 checks passed
@Helias
Copy link
Member

Helias commented Nov 7, 2025

I did some tests locally, I don't think that this code is really necessary, ERSU.db.dist has already the Article table apparently, it does not need this code, I would keep it to prevent any issues.

Possibly, the docker image in the github docker hub (ghcr) was not updated yet and you were using the old image instead of the new one.

@Giuseppe-Tornello
Copy link
Contributor Author

Possibly, the docker image in the github docker hub (ghcr) was not updated yet and you were using the old image instead of the new one.

I was building the image locally, so actually idk why renaming the .db.dist did not work.
I probably did a mess with the -v parameters since one of the parameters was
:/**app**/data/ERSU_DB.db
:/**ersubot**/config/settings.yaml

but as you said it might prevent some issues so it is not 100% useless

@Giuseppe-Tornello Giuseppe-Tornello deleted the test_2 branch November 8, 2025 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants