3 ms·
I'm pretty comfortable in SQL but I've found myself lazily reaching for SQLA recently to run queries that I would normally do in SQL. For example session.q
by aidos 11y ago
I'm pretty comfortable in SQL but I've found myself lazily reaching for SQLA recently to run queries that I would normally do in SQL. For example
session.query(Thing1).join(Thing2).join(Thing3).filter(Thing3.name.like('%easy%'))
I'll be in the middle of firing up psql and then I'll think about writing out my joins and laziness wins out. For more complex stuff I normally go back to SQL, but mostly because I'm less familiar with constructing some of the more complex queries in SQLA (though I'm slowly pushing myself to learn more).
- mhd 11y agoI use Ruby for the same thing, especially when it's spanning databases. Sequel+Pry are a pretty decent environment for quickly anlayzing, syncing and updating stuff. Maybe I'll have to take a second look at SQLAlchemy's query builder plus ipython/bpython... In actual code, I'm actually pretty content with raw SQL (wrapped in Perl's DBIx::Simple these days), as I prefer to move the more complicated things to functions/views before constructing elaborate abstractions in-place. Complex ad-hoc queries are another issue, of course...