通过JDBC解决Python在ARM上的Oracle访问

Oracle Client是一套闭源的客户端,在哪个平台上可以使用完全由Oracle官方决定。如附录所示,Oracle Client并不直接支持ARM上的访问。

那么是不是Python等语言就无法在ARM上访问Oracle了呢?在Stackoverflow上也有人讨论了这样几个方法:

在Stackoverflow上,已经有人验证过树莓派ARM访问Oracle数据库。 https://stackoverflow.com/questions/56838410/problem-classpath-for-jaydebeapi-from-raspberry

$ pip install JayDeBeApi
>>> import jaydebeapi
>>> #conn = jaydebeapi.connect("org.hsqldb.jdbcDriver",
... #                          "jdbc:hsqldb:mem:.",
... #                          ["SA", ""],
... #                          "/path/to/hsqldb.jar",)
>>> conn=jaydebeapi.connect(oracle.jdbc.driver.OracleDriver,
[admin]/[root]@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=helloworld.com)(PORT=1521))(CONNECT_DATA=(SID=hello42))),
jars=/home/pi/ojdbc6.jar)
>>> curs = conn.cursor()
>>> curs.execute(create table CUSTOMER
...                ("CUST_ID" INTEGER not null,
...                 "NAME" VARCHAR not null,
...                 primary key ("CUST_ID"))
...             )
>>> curs.execute("insert into CUSTOMER values (1, John)")
>>> curs.execute("select * from CUSTOMER")
>>> curs.fetchall()
[(1, uJohn)]
>>> curs.close()
>>> conn.close()

附录,Oracle客户端支持的平台。 Oracle Instant Client Downloads Instant Client for Microsoft Windows

Instant Client for Microsoft Windows (x64) Instant Client for Microsoft Windows (32-bit) Instant Client for Microsoft Windows 64-bit Itanium Instant Client for macOS

Instant Client for macOS (Intel x86) Instant Client for Mac OS X (PPC) Instant Client for Linux

Instant Client for Linux x86-64 Instant Client for Linux x86 Instant Client for Linux AMD64 (32-bit and 64-bit) Instant Client for Linux on Power Big Endian (32-bit) Instant Client for Linux on Power Big Endian (64-bit) Instant Client for Linux on Power Little Endian (64-bit) Instant Client for z/Linux (31-bit) Instant Client for z/Linux (64-bit) Instant Client for Linux Itanium Instant Client for Solaris

Instant Client for Solaris Operating System (SPARC) (64-bit) Instant Client for Solaris Operating System (SPARC) (32-bit) Instant Client for Solaris x86-64 Instant Client for Solaris x86 Instant Client for HP

Instant Client for HP-UX PA-RISC (64-bit) Instant Client for HP-UX PA-RISC (32-bit) Instant Client for HP Tru64 UNIX Instant Client for HP-UX Itanium (64-bit) Instant Client for HP-UX Itanium (32-bit) Instant Client for AIX

Instant Client for AIX (PPC64) Instant Client for AIX (PPC32)

经验分享 程序员 微信小程序 职场和发展