Is it possible to use django-pyodbc with iSeries Access ODBC Driver? - python

I am trying to get Django-pyodbc to work with DB2 on IBM i using the standard IBM i Access ODBC driver.
I know there is a Django DB implementation supported by IBM, but that requires the DB2 Connect product, which is (for us) prohibitively expensive, whereas the included Access ODBC driver comes no-charge with the OS.
I have seen a question asked regarding django-pyodbc with iSeries ODBC, suggesting that it is possible, but I have found no way to get it to work:
https://stackoverflow.com/questions/25066866/django-inspectdb-on-db2-database
My first question therefore is; has anybody succeeded in getting this setup to work?
And if yes, can you share information on how you did it?
Thanks,
Richard

Related

Connecting Caché database in Azure function

I'm looking to a way to "simply" access to a Caché database using python (I need to make sql query on this database).
I've heard about a python package (Intersys) but I can't find it anymore (having this package would be the most simple way).
I've tried using pyodbc connection with the appropriate Caché driver : it works on my machine, however when I try to deploi the function in production (Linux OS), the driver's file is not found.
Thank you
There is only one way, on how to make it work with Python, is using pydobc, and InterSystems driver.

Is there a Python library for Oracle SQL?

I've been looking across the internet to find some sort of library that will connect an Oracle database to a Python script, but so far I have been unsuccessful. If anyone has found a great library for Oracle, preferably first party, then please give me documentation. I'm working on a project now that particularly needs this integration. I've already seen lots of documentation for MySQL, which is maintained by Oracle, but that's about it.
The library is cx_Oracle. It conforms to the Python DB API 2.0 specification with a number of additions and a couple of exclusions. The cx_Oracle creator is Anthony Tuininga. Since 2017 the cx_Oracle is manteined by Oracle and Anthony Tuininga joined to Oracle and making maintaining the driver his full time job.
The lib have a good documentation and are frequently updated. There are a bunch of samples on cx_Oracle github.
Oracle provides the python library cx_Oracle. Like everything else produced by Oracle, the documentation leaves some to be desired and the drivers are an absolute pain in the ass, but it works.

Python Code from Databricks to connect to SQL server

I am trying to execute a python code from Databricks which primarily establish a connection from Python to SQL server using JDBC.
I used 'jaydebeapi' python library and when I run the code it gives error saying "JayDeBeApi throws AttributeError: '_jpype.PyJPField' object has no attribute 'getStaticAttribute' "
I searched in the internet and found the Jpype library is used in jaydebeapi is the problem and I downgraded the same to 0.6.3 version.
But still I am getting the same error. Can anyone explain me how to make this change and run in databricks.
Or is there any alternative library which I can use.
Why not directly follow the offical documents of databricks below to install Microsoft JDBC Driver for SQL Server for Spark Connector and refer to the sample code of Python using JDBC connect SQL Server.
SQL Databases using the Apache Spark Connector
SQL Databases using JDBC and its Python example with the jdbc url of MS SQL Server
If you were using Azure, there are the same documents for Azure Databricks, as below.
SQL Databases using the Apache Spark Connector for Azure Databricks
SQL Databases using JDBC for Azure Databricks
This is a known issue with JayDeBeApi, you may check out the issue on GitHub.
Due to a bug in 0.6.3 private variables were exposed as part of the interface. Also 0.6.3 had a default class customizer which automatically created a property to get and set if the methods matched a Java bean pattern. This property customizer was loaded late after many common java.lang classes were already loaded, and was not retroactive thus only user loaded classes that happened after initializer would have the customization. The private variable bug would mask the property customizer as the property customizer was not to override fields. Some libraries were unknowingly accessing private variables assuming they were using the property customizer.
The customizer was both unnecessary and resulted in frequent errors for new programmers. The buggy behavior has been removed and the problematic property customizer has been disable by default in 0.7.
Add lines to the module to enable the old property behavior. But this will not reenable the previous buggy access to private variables. Thus code that was exploiting the previous behavior which bypassed the getter/setter of java will need to use the reflection API.
To enable the property customizer, use
try:
import jpype.beans
except ImportError:
pass
Hope this helps.

pyodbc vs ADO via COM for Python scripts

For many years, my company has used the win32com module and ADO to connect to databases via ODBC in Python scripts. I do not like ADO because it is ancient and because COM is inherently slow and because it tends to throw one particular exception for which there is no workaround I've ever found. We use ODBC because we cannot assume that our customers have any particular database system (although most of them use PostgreSQL). We have a class that wraps ADO and provides access to most (maybe all) of the functionality in ADO. I am at a point where I could recommend a complete changeover to pyodbc. Before I do that, I'm curious: are there advantages to ADO via win32com? Does it have more capability than pyodbc?
are there advantages to ADO via win32com? Does it have more capability than pyodbc?
Practically speaking, and specifically with regard to ODBC, not really. ADODB would have the advantage of being able to use an OLEDB provider for a database that had an OLEDB provider but not an ODBC driver, but that would be a rare occurrence. (The only such database I can recall is "SQL Server Compact Edition", which was discontinued long ago.)
As mentioned in the comments to the question, pyodbc would have the advantage of avoiding extra layers of middleware when communicating with the database, i.e.,
your Python app ↔ pyodbc ↔ ODBC Driver Manager ↔ ODBC Driver ↔ database
vs.
your Python app ↔ win32com ↔ ADODB ↔ OLEDB provider for ODBC ↔ ODBC Driver Manager ↔ ODBC Driver ↔ database
As also mentioned, win32com/ADODB is a Windows-only technology, whereas a pyodbc solution could also be deployed on Linux or Mac if the appropriate ODBC drivers were available for those platforms.

Remote access to MySQL DB hosted in OpenShift (not looking for the port forwarding solution)

I spent the whole yesterday migrating my django application to OpenShift (I selected the free solution and my application is using one small gear). My application is now up and running and there are no issues visiting the site using a browser.
However I have a .NET (C#) application which accompanies the web application and it will be run by many different users and it needs to access the database but I can not find a way to do this in OpenShift.
All the different IP addresses seems to be local and I can not find a way to access the MySQL database remotely. Below are the environment variables from OpenShift:
env | grep MYSQL
OPENSHIFT_MYSQL_DIR=/var/lib/openshift/.../mysql/
OPENSHIFT_MYSQL_DB_PORT=3306
OPENSHIFT_MYSQL_DB_HOST=127.13.169.130
OPENSHIFT_MYSQL_DB_PASSWORD=...
OPENSHIFT_MYSQL_IDENT=redhat:mysql:5.5:0.2.9
OPENSHIFT_MYSQL_DB_USERNAME=...
OPENSHIFT_MYSQL_DB_SOCKET=/var/lib/openshift/.../mysql//socket/mysql.sock
OPENSHIFT_MYSQL_DB_URL=mysql://..-...#127.13.169.130:3306/
OPENSHIFT_MYSQL_DB_LOG_DIR=/var/lib/openshift/.../mysql//log/
OPENSHIFT_MYSQL_LD_LIBRARY_PATH_ELEMENT=/opt/rh/mysql55/root/usr/lib64
As explained in the title I am not looking for the port forwarding solution. (I need to make it work not only for me but all the users)
What am I missing?
Why can't databases be accessed externally?
What should I do?
Are there any other FREE paas out there which offer what I am looking for?
Do I need to get a medium or big gear in order for this to work?
Thanks
If you don't want to use port forwarding, then I would suggest you write an API that your .NET application can use to access the database. Otherwise you would want to look into an externally hosted database (DBaaS) solution.
OK, lots of googleing and I now know that using the free solution provided by OpenShift it is not possible to solve this issue.
You must upgrade to a paid version in order to get another port to access the sql database directly.

Categories

Resources