Cx_oracle With Multiple Oracle Client Versions
Solution 1:
Although in theory you should be able to build an Oracle 11g version of cx_Oracle and use it with both an Oracle 11g and Oracle 12c client, I wouldn't recommend it. If you are able to convince your users to use the Oracle 12c instant client that would be the simplest. That client is able to access both 11g and 12c databases without any difficulty. But if that isn't possible, the other option is the following:
1) Compile cx_Oracle for both 11g and 12c and place both copies in your installation named (for example) cx_Oracle_11g.so and cx_Oracle_12c.so.
2) Import cx_Oracle dynamically using code like the following:
for version in("11g", "12c"):
fileName = os.path.join(installDir, "cx_Oracle_%s.so" % version)
try:
module = imp.load_dynamic("cx_Oracle", fileName)
break
except ImportError:
pass
3) Use the dynamically imported module wherever you need it in the same way as before. Since the dynamically loaded module was named cx_Oracle you should be able to import it in other code in the regular way and it will find the one you dynamically loaded.
4) Use cx_Oracle 6.x which supports any Oracle Client 11.2, 12.1 and 12.2 at the same time.
Post a Comment for "Cx_oracle With Multiple Oracle Client Versions"