[Tutor] How to write database-agnostic python code? (Is this even possible?)
Maxime S
maxischmeii at gmail.com
Wed Sep 13 14:17:06 EDT 2017
2017-09-13 3:58 GMT+02:00 boB Stepp <robertvstepp at gmail.com>:
> On Tue, Sep 12, 2017 at 2:17 PM, Mats Wichmann <mats at wichmann.us> wrote:
> > On 09/12/2017 01:05 PM, boB Stepp wrote:
> >> As I continue to read about SQL, one thing jumps out: There are many
> >> differences between how SQL statements are implemented among the
> >> different database products. Even for relatively simple,
> >> straightforward things like field concatenation. One DB might use
> >> "||" as the operator. Another uses "+". Yet another only uses a
> >> "CONCAT" function. This is crazy!
>
> [...]
>
> > But dealing with "local extension to SQL" is a different problem. SQL
> > is actually a standard and should work the same everywhere, but then
> > people decide they need to improve it. Being agnostic means avoiding
> > mysql-specific syntax, postgres-specific syntax, etc. Which means you
> > need to know what is specific in the first place...
>
> In the example I was alluding to, concatenating fields, surely this is
> a "standard SQL" query? So, for instance, if I had a Sales table with
> FirstName and LastName fields and wanted to use SQL to get the full
> name from these:
>
Concatenation is indeed part of the ISO standard (using the || operator).
Unfortunately no DB respect the standard 100%.
There is a nice comparaison of the different behaviours here:
http://troels.arvin.dk/db/rdbms/
It is very hard to create an application that is truly DB-independent. Most
applications just pick one and then have to stick with it ever after.
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Garanti
sans virus. www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
More information about the Tutor
mailing list