Skip to content

Unable to INSERT/UPDATE to Postgres SQL Database on Heroku #118 #128

Closed
@beowolx

Description

@beowolx

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

kzidane commented on Aug 27, 2020

@kzidane
Member

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

beowolx commented on Aug 27, 2020

@beowolx
Author

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

kzidane commented on Aug 27, 2020

@kzidane
Member

@LuisFlavioOliveira actually just to double-check something, does your table not have a primary key?

beowolx

beowolx commented on Aug 27, 2020

@beowolx
Author

Indeed, it has not a primary key.

beowolx

beowolx commented on Aug 27, 2020

@beowolx
Author

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

lvolcov commented on Aug 27, 2020

@lvolcov

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

ThomasVanRymenant commented on Nov 13, 2020

@ThomasVanRymenant

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

dmalan commented on Nov 22, 2020

@dmalan
Member

Hi all, sorry for the quietude. If you do pip3 show cs50, what version are you using if still seeing this error?

beowolx

beowolx commented on Nov 22, 2020

@beowolx
Author

Hi all, sorry for the quietude. If you do pip3 show cs50, what version are you using if still seeing this error?

Hi @dmalan,

Thanks for your answer.

I'm using the version: 5.0.4.

dmalan

dmalan commented on Nov 22, 2020

@dmalan
Member

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 your requirements.txt to contain:

git+git://github.com/cs50/python-cs50@transactions

instead of just:

cs50
dmalan

dmalan commented on Nov 29, 2020

@dmalan
Member

This should now be fixed as of >= 6.0.1!

AtharvaKirkole

AtharvaKirkole commented on Feb 1, 2022

@AtharvaKirkole

Hello im still facing the Exact same issue described by LuisCardosoOliveria

reopened this on Feb 6, 2022

10 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @dmalan@kzidane@ThomasVanRymenant@beowolx@lvolcov

    Issue actions

      Unable to INSERT/UPDATE to Postgres SQL Database on Heroku #118 · Issue #128 · cs50/python-cs50