I found that some people use sqlalchemy ORM to query data, but use sqlalchemy CORE to insert data. why did they do that way? why don't they keep it consistent in one Python code(class)?
Sqlalchemy ORM will translate to CORE finally, right? Using core and orm ,at the same time, is that make program quicker? I found a sentence here (What is the difference between sqlalchemy core and ORM?)
particularly based on information only available at runtime
does that mean CORE is quicker or what? I am really confused about it. anyone can help, thanks in advance.
You should have a look at this performance comparison and explanation in the docs. Basically it explains how and why the ORM is not suited for large bulk inserts that the Core might handle just fine. There are bulk operations available in the Session as well, but they have their trade-offs.
While the ORM is indeed built on top of the Core, it does a lot more than just simple "save these objects to a database". It tracks changes to objects in the session and flushes those pending changes to the DB periodically. This is part of the unit of work pattern. All that book keeping comes with a price, but in return you don't have to worry as much about the order of operations when persisting a complex object graph in to a relational database. Sometimes you don't need all that and want just to insert a bunch of rows in to a database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With