-
Notifications
You must be signed in to change notification settings - Fork 253
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
sqlAlchemy never insert data to the database,! #70
Comments
I found the problem, it doesn't support InnoDB store engine,,, but worckbench default set to it. |
That is strange, travisci tests |
i didn't try pool or single connect yet, I just try aiomysql type of sqlalchemy. |
Could you check your MySQL version and configured engine? |
Hi, @xinghanchuanqizibenguanliyou |
@popravich I have 3 tables, and i can't see the data be inserted by mysql client. What's more, i changed the engine to be MyISAM, all goes well. |
Are there any errors or exceptions?
|
Just my guess - I'd vote for settings |
@rudyryk yeah, must run " yield from conn.execute('commit') " after every insertion. |
@rudyryk but you can't explain it goes well with MyISAM db engine. |
@xinghanchuanqizibenguanliyou Not sure, but I suppose engines just deal a little bit differently with commit policy :) |
|
@jettify I don't recommend you change it, for the sake of efficient. it will goes well when write such code: |
@xinghanchuanqizibenguanliyou Not sure about efficiency, the Tip 5 from Instagram team claims that I think that backwards compatibility is far more important and such change would require wider discussion. That's why I said that I would vote :) And I've occasionally found the answer to your question about the difference between InooDb/MyISAM: "autocommit is on by default for InnoDB - MyISAM doesn't support transactions." http://stackoverflow.com/questions/2950676/difference-between-set-autocommit-1-and-start-transaction-in-mysql-have-i-misse @jettify Oh, I see. Well, OK - probably that's important for people who migrate their code from sync to async. I don't really know if there are many of them :) For starting a new project from scratch with the new approach, autocommit model just seems more clear to me -- if you don't explicitly start a transaction, queries are performed immediately, and that's the default behavior for MySQL, after all :) |
@jettify Oh, and the initial issue is not with raw queries, it's about sqlAlchemy. As far as I know, if no transaction is defined, queries are committed automatically. The example in "Example of SQLAlchemy optional integration" doesn't contain |
good question! |
well i think this way well more efficient than below:
that is what @xinghanchuanqizibenguanliyou mean. |
@jettify As I understand sqlAlchemy original engine implements auto-commit logic by default for queries executed outside of a session, as they call it. And this is independent on underlying database, as long it's ORM and all code has to be database agnostic as much as possible. I'm not sure how to deal with this case. I see two options:
The first options seem correct to me if connections created for sqlAlchemy are only used by sqlAlchemy (not used separately for raw queries). Otherwise I'd look at second option. |
I use the example you give.
The text was updated successfully, but these errors were encountered: