Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tokio postgres built-in droppable transaction in txn example #111

Merged
merged 1 commit into from
Oct 25, 2021

Conversation

film42
Copy link
Contributor

@film42 film42 commented Oct 23, 2021

Looks like tokio_postgres::Transaction is a more official transaction type that will automatically rollback if it has not been committed when dropped. I like the explicit BEGIN/COMMIT/ROLLBACK, but I think it's better to use the tokio_postgres crate features.

With this change, should #20 be closed?

Happy hacktoberfest!

@djc
Copy link
Owner

djc commented Oct 24, 2021

Thanks, I think that makes sense. I would prefer to keep it all inline though, instead of extracting a function for running the query.

Looks like tokio_postgres::Transaction is a more official transaction type
that will automatically rollback if it has not been committed. I like
the explicit BEGIN/COMMIT/ROLLBACK, but I think it's better to use the
tokio_postgres crate features.
@film42
Copy link
Contributor Author

film42 commented Oct 25, 2021

Added the function to avoid .unwrap() after most statements, but I know what you mean. I pulled it back into one function.

@djc djc merged commit 8446fb8 into djc:main Oct 25, 2021
@djc
Copy link
Owner

djc commented Oct 25, 2021

Thanks!

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.

None yet

2 participants