SQL transactions

The following paragraph is confusing me because of the grammatical errors:

" However, until close the connection your future queries using that same connection will already take these changes into account as if they had been committed. They will remain invisible for other users only until you commit. If you close the connection before committing them, then they will simply disappear. This means that during that time, not everyone will have the same view over the database."

The paragraph above seems to suggest that even if you don’t commit the transaction, you will have the changes take place (and none of the other users will see the change).

Can someone re-state what this is saying in a clearer way? My understanding up to this point was that changes to the database do not take effect until you commit the transaction. In Section 5, we even run a query to access the users table and correctly get an error because we didn’t commit the SQL transaction that had the command for creating the table.

My best guess is that between Section 4 (when we create the users table) and Section 5, we actually create a new connection instance (even though the variable name is the same) so the changes are not reflected in the new connection instance in Section 5. That is why when we try to query the users table in section 5, we get an error because we never committed the SQL transaction in Section 4 and are now operating under a new connection in Section 5. If this is correct, then this should be explained better.

1 Like

Hi @werst004,

Thank you for pointing this out. I will put some time soon to improve this explanation.

The way it works is that until you commit your changes, those changes and only visible to you. However, if you close the connection used to make those changes, they will completely disappear.

I hope that clarifies it :slight_smile:

1 Like