[Tutor] How to write database-agnostic python code? (Is this even possible?)

Peter Otten __peter__ at web.de
Thu Sep 14 03:06:59 EDT 2017


boB Stepp wrote:

>> at some point you will need to write database specific SQL or delegate
>> that task to a library -- sqlalchemy was already mentioned. I suspect
>> that you will then end up learning both the SQL dialects and the ORM
>> API...
> 
> I maybe did not realize the full import of Albert-Jan's suggestion
> then.  Will sqlalchemy (Or a similar product.) totally abstract away
> these annoying SQL variations amongst db vendors?

While I have absolutley no experience with sqlalchemy I would be surprised 
if it didn't abstract away the common variations like concatenation.
I would be even more surprised if there weren't any operations, vendor-
specific or standardised, that can be performed with SQL, but not highlevel  
sqlalchemy.

That's the "Law of leaky abstractions",
https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/




More information about the Tutor mailing list