[Tutor] How to write database-agnostic python code? (Is this even possible?)
boB Stepp
robertvstepp at gmail.com
Tue Sep 12 15:05:39 EDT 2017
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!
It almost seems like I would need to write a DB-translator class that
takes a SQL statement (In some DB's version) and the target DB as
inputs, and then translates the statement into that DB's particular
usage of SQL. So how does one write one's python program to be
DB-agnostic? And if this is impossible, then what is the best way to
structure the overall program to isolate this SQL-specific stuff by
itself, insofar as possible, so any migrations to a new DB type is as
easy as possible?
--
boB
More information about the Tutor
mailing list