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

BUG: data written with to_sql legacy mode (sqlite/mysql) not persistent GH6846 #6875

Merged
merged 1 commit into from
Apr 13, 2014

Conversation

Acanthostega
Copy link
Contributor

I added a call to commit method for pushing data into the SQL database and not only in the memory.
Tests are updated too in order to avoid future regression with a closed connection between writing and reading in the database. Since all the data in a memory based database in sqlite3 should be removed when closed, I create a temporary file used as database. The NamedTemporaryFile documentation states that it should be cross platforms but I don't have any Windows to test it. Normally doesn't break something. I never have done a pull request before, so let me know if something is bad. It's my first time and I'm happy to do it with pandas...

Closes #6846

@@ -507,8 +509,71 @@ class TestSQLLegacyApi(_TestSQLApi):
"""
flavor = 'sqlite'

def connect(self):
return sqlite3.connect(':memory:')
def setUp(self):
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it is needed to repeat that here (the setUp function I mean). Just call self._load_test2_data in the beginning of your test test_sql_open_close

@jorisvandenbossche
Copy link
Member

@Acanthostega Thanks a lot! Already looking good, just some comments.
If you address them, you amend the commit and then push force again (git push -f origin), and the PR will automatically update.

BTW, we always recommend to make a seperate branch for a PR (so you don't work on the master branch). It's OK for now, but if you would contribute more in the future, it's better to commit changes directly to master.

If you have further questions, just ask!

@Acanthostega
Copy link
Contributor Author

I made modifications according to comments and also added corrections in the code for pep8. There was importations of pymysql and psycopg2 not used so I removed them (maybe I'm wrong and they are useful).

I have a question about branches. If I have modifications to done, I create my personal branch, make modifications, commit and push my branch into the fork (without merging to master). Then for the pull request, I specify that I want to merge my branch to the master one of pandas. Am I right or should I put it in an other branch?

@cpcloud
Copy link
Member

cpcloud commented Apr 12, 2014

That's correct.

@jorisvandenbossche
Copy link
Member

@Acanthostega Sorry, we should maybe be clearer about this, but in general we don't like such massive PEP8 changes in the same commit for another change. In a PR, just make sure that the new code for the contribution or the fix follows PEP8, but for cleaning up other code we like to do this seperate and at certain moments (to keep history and git blame cleaner, and to not get too much conflicts with other PRs).
And furthermore, it also makes it more difficult to review this PR (to see what is really changed).

So could you seperate the actual fix and tests here?

But for the branch, like @cpcloud said, you are correct. Normally this is also what github will propose by default.

sql.has_table(
'test_frame1',
self.conn,
flavor='sqlite'
Copy link
Member

Choose a reason for hiding this comment

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

This is also not really PEP8, these can stay on one line up to 80 chars.

@jorisvandenbossche jorisvandenbossche added this to the 0.14.0 milestone Apr 12, 2014
@Acanthostega
Copy link
Contributor Author

I updated to only put tests without pep8 corrections. I should have read with more attention the guidelline for contribution before, since all is clear inside!

Now, if tests pass, I have to update changelog file in an other commit. Am I right?

@jorisvandenbossche
Copy link
Member

Looking good! I tested the test and it works, and also Travis is green.

I think adding something to the changelog is not really necessary, as this fixes something that was not yet released (there will be one big item in the changelog about all sql stuff that is improved).
But just a last question: can you squash the two commits? Then it is good to merge!

…nt GH6846

Correction for missing commit of data into SQL database in legacy code and add test to avoid future regression.

Correct tests according to comments
@Acanthostega
Copy link
Contributor Author

I think it should be OK, except the commit message maybe...

@jorisvandenbossche
Copy link
Member

@Acanthostega Thanks a lot for your contribution! Merging now

If you would want to tackle other issues on sql (see the list here #6292), let you go :-)

jorisvandenbossche added a commit that referenced this pull request Apr 13, 2014
BUG: data written with to_sql legacy mode (sqlite/mysql) not persistent GH6846
@jorisvandenbossche jorisvandenbossche merged commit f7205b5 into pandas-dev:master Apr 13, 2014
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.

BUG: data written with to_sql legacy mode (sqlite/mysql) not persistent
4 participants