Description
This was an issue that was previous posted here under the #118 and it was closed by the staff with the argument that it was fixed but it hasn't been.
I'm trying to deploy an app on Hedoku using the latest version of CS50 and the bug still there. I'm gonna just copy and paste the original message from #118 cause it's exactly the same problem:
"After completing the CS50 Finance assignment, I attempted to move the application to Heroku. I converted the SQLite3 database over to Postgres. I am able to connect to the Heroku database using:
from CS50 import SQL
db = SQL("Heroku---URI")
SELECT statements do work and does retrieve the requested data. However, INSERT and UPDATE statements did not work for me. I was able to INSERT and UPDATE to the database using my computer's command line, as well as from pgAdmin 4.
Finally, I was able to get my CS50 Finance working by importing the sqlalchemy module instead, and adding .fetchall() to the end of SELECT statements and after INSERT/UPDATE statements I added the db.commit() statement in a line below it to save the changes.
I didn't see any additional notes (such as .commit()) in the documentation on how to get the CS50 module to work with a Postgres database. Sorry in advance if there's something that I missed. CS50 is such a tremendous class by the way, it's absolutely brilliant! 👍"
Activity
kzidane commentedon Aug 27, 2020
Hi @LuisFlavioOliveira! Thanks for opening this issue! I can confirm that the issue still exists, but it's caused by something different. We'll deploy a fix asap.
beowolx commentedon Aug 27, 2020
Hello @kzidane, thanks for your reply.
Nice! I'm gonna fork and see if I can help you guys too.
Wish you a good day,
Luis
kzidane commentedon Aug 27, 2020
@LuisFlavioOliveira actually just to double-check something, does your table not have a primary key?
beowolx commentedon Aug 27, 2020
Indeed, it has not a primary key.
beowolx commentedon Aug 27, 2020
So, to be more precise: The 'INSERT' works perfectly with a table that has a primary key but not with tables using foreign keys (just tested it).
lvolcov commentedon Aug 27, 2020
I am having the exact same problem, I can see my update and insert going through the application but it doesn't change my Postgres. When I try to execute the exact same SQL command on the https://adminer.cs50.net/ it works.
Thank you in advance! 👍🏻
ThomasVanRymenant commentedon Nov 13, 2020
This bug still seems to exist. My final project on heroku has been encountering problems with writing-queries as well. The strange thing is that altho the insert queries do not work the majority of the time, sometimes they actually do work...
Is this bug still being looked at or is supposed to be fixed?
Since insert queries work on tables with a primary key, would it be an acceptable solution to give a primary key to all tables that don't have one already (not to use but to bypass this bug)?
Any help/advise would be much appreciated
dmalan commentedon Nov 22, 2020
Hi all, sorry for the quietude. If you do
pip3 show cs50
, what version are you using if still seeing this error?beowolx commentedon Nov 22, 2020
Hi @dmalan,
Thanks for your answer.
I'm using the version: 5.0.4.
dmalan commentedon Nov 22, 2020
Thanks, @LuisFlavioOliveira. We're still testing on our end too, but want to try out the
transactions
branch in the meantime, https://github.com/cs50/python-cs50/tree/transactions? Should suffice to update yourrequirements.txt
to contain:instead of just:
dmalan commentedon Nov 29, 2020
This should now be fixed as of >= 6.0.1!
AtharvaKirkole commentedon Feb 1, 2022
Hello im still facing the Exact same issue described by LuisCardosoOliveria
10 remaining items