How to write custom database adapter for django using JDBC drivers?

笑着哭i 提交于 2021-02-19 12:55:46

问题


I have a web-app in Django and backend in Hbase. To access hbase I'm using Apache Phoenix to query hbase. Phoenix has jdbc drivers exposed.

How can I integrate Phoenix with Django ORM using these jdbc drivers? Can I write customer db adapter or is there any other way?

Thanks in advance.


回答1:


I have also been trying to see if it is possible to extend the ORM of django to use apache phoenix. but for a start, you can checkout

JayDeBeAPI

or

phoenixdb

As an example, I was able to connect and retrieve data using the phoenixdb package.

  1. Install the package via pip install phoenixdb
  2. Run the sample code:

    import phoenixdb

    database_url = 'http://localhost:8765/?v=1.6'

    conn = phoenixdb.connect(database_url, autocommit=True)

    cursor = conn.cursor()

    cursor.execute('select * from WEB_STAT limit 1')

    rs = cursor.fetchall()

    print rs

It is important to know the version of the phoenix you are using, you can find the details in the link provided.



来源:https://stackoverflow.com/questions/37708696/how-to-write-custom-database-adapter-for-django-using-jdbc-drivers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!