|
|
|
|
|
by zzzeek
2389 days ago
|
|
> It supposedly promises you that you don't need to know SQL to use please support this assertion with an ORM whose documentation promises this. > ORM constantly will make unnecessary SQL queries and by default request all fields, as does "SELECT * FROM table" if you don't write out the fields and use a buffering database adapter (which is the case for nearly all Python database adapters), so, when using an ORM, you need to give it instructions over what columns you need to fetch. This is not unusual nor even anything a library could possibly guess for you if you do not give it this intent. |
|
I don't think any ORM would officially claim that, but many people decide to go that way to avoid SQL. For many simple examples it looks simpler than SQL.
I also experimented myself and wrote my code using SQLAlchemy's ORM. Then edited my code to use psycopg2 natively. I realized that SQLAlchemy didn't save any code for me, in fact it was more verbose. It also heavily encouraged me to get the raw data from database and do processing of it in the application. It also did unnecessary extra queries.
So with it now I need to:
1. still understand SQL
2. trying to figure how to write the SQL statement using ORM
3. figure out how to make ORM not to do extra queries
> as does "SELECT * FROM table" if you don't write out the fields and use a buffering database adapter (which is the case for nearly all Python database adapters), so, when using an ORM, you need to give it instructions over what columns you need to fetch. This is not unusual nor even anything a library could possibly guess for you if you do not give it this intent.
My problem is that in addition to knowing SQL, I also need to know how to do in that specific ORM that's for the specific language I'm using.