raskitoma / pls_admin

A tool designed to manage and control your withdrawal history
https://raskitoma.com
1 stars 2 forks source link

docker exec -it adminpls python3 -m flask scheduler-reset ---> fails to run #10

Open terry-sydaus opened 3 months ago

terry-sydaus commented 3 months ago
docker exec -it adminpls python3 -m flask scheduler-reset

The above command produces an error when it gets to the TRUNCATE TABLE sql command, as shown below.

sqlalchemy.exc.ArgumentError: Textual SQL expression 'TRUNCATE TABLE task_scheduler C...' should be explicitly declared as text('TRUNCATE TABLE task_scheduler C...')
terry-sydaus commented 3 months ago

Problem solved.

I added the following import statement:

from sqlalchemy import text

And modified the TRUNCATE TABLE lines of code, as follows:

t = text("TRUNCATE TABLE task_scheduler CASCADE")
db.session.execute(t)
#db.session.execute('TRUNCATE TABLE task_scheduler CASCADE')
t = text("TRUNCATE TABLE task_list CASCADE")
db.session.execute(t)
#db.session.execute('TRUNCATE TABLE task_list CASCADE')

Where it can be seen that I used the text method to create a sql variable that could be interpreted by sqlalchemy package.

Happy days!