如何使用JDBC驱动程序为Django编写自定义数据库适配器? [英] How to write custom database adapter for django using JDBC drivers?
问题描述
我在Django中有一个Web应用,在Hbase中有一个后端.要访问hbase,我正在使用Apache Phoenix查询hbase. Phoenix公开了jdbc驱动程序.
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.
如何使用这些jdbc驱动程序将Phoenix与Django ORM集成在一起? 我可以编写客户数据库适配器还是其他方法?
How can I integrate Phoenix with Django ORM using these jdbc drivers? Can I write customer db adapter or is there any other way?
谢谢.
推荐答案
我也一直在尝试查看是否有可能将django的ORM扩展为使用apache phoenix.但首先,您可以结帐
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
JayDeBeAPI
或
作为一个例子,我能够使用phoenixdb软件包连接和检索数据.
As an example, I was able to connect and retrieve data using the phoenixdb package.
- 通过pip install phoenixdb安装软件包
-
运行示例代码:
- Install the package via pip install phoenixdb
Run the sample code:
导入phoenixdb
import phoenixdb
database_url =' http://localhost:8765/?v = 1.6 '
database_url = 'http://localhost:8765/?v=1.6'
conn = phoenixdb.connect(database_url,autocommit = True)
conn = phoenixdb.connect(database_url, autocommit=True)
cursor = conn.cursor()
cursor = conn.cursor()
cursor.execute('从WEB_STAT限制1中选择*'
cursor.execute('select * from WEB_STAT limit 1')
rs = cursor.fetchall()
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.
这篇关于如何使用JDBC驱动程序为Django编写自定义数据库适配器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!