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

including the last inserted row id if available #5

merged 2 commits into from Dec 30, 2020


Copy link

I find it very useful to have the id of the last row that has just been inserted.

Before this change, executing insert query would result in something of the form

{'error': None, 'items': [], 'row_count': 1}

after this change we get something like

{'error': None, 'items': [], 'lastrowid': 7, 'row_count': 1}

Copy link

@aosingh aosingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @marekyggdrasil

Thank you for creating a pull request.

We could simplify the code and remove variables lastrowid and ret

As documented here, lastrowid is either set or it is None. So, something like this would be simple.

if self._cursor.lastrowid:
    result['lastrowid'] = self._cursor.lastrowid

Copy link
Contributor Author

Great suggestion @aosingh thanks for reviewing the PR. I just implemented the change you requested. Feel free to let me know if something more is required.

@aosingh aosingh merged commit 2968a65 into aosingh:master Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants