如何编写自定义django关系数据库后端 [英] how to write a custom django relational database backend

查看:114
本文介绍了如何编写自定义django关系数据库后端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的django应用程序需要支持来自复合软件支持的数据源的数据。 Composite通过jdbc / odbc公开其数据,但它使用非标准的sql语法。我已经尝试使用django-pyodbc作为后端引擎,但是它在连接初始化时立即错误,因为它在Composite不支持的语法中发送硬编码的初始化命令(如 SET ... )。

My django app needs to support data coming from a datasource backed by Composite Software. Composite exposes its data over jdbc/odbc, but it uses non-standard sql syntax. I've tried using django-pyodbc as the backend engine, but it errors out immediately on connection initialization as it's sending hardcoded initialization commands in syntax that Composite doesn't support (like SET ...).

显然,最简单的方法是直接对pyodbc进行编码。但是,在我走下去之前,我想探讨编写自定义后端的可能性。我看过一些为非关系后端编写的django-backend模板。不过,我还没有找到类似的关系数据库模板。这样的事情存在吗?任何其他建议?

The easiest way to get this to work, obviously, is to simply code directly against pyodbc. But before I go down that route, I'd like to explore the possibility of writing a custom backend. I've seen a couple of django-backend templates written for non-relational backends. I haven't been able to find a similar template for relational databases, though. Does such a thing exist? Any other recommendations?

推荐答案

我认为SQLite关系后端很简单,如果你想走这条路,也许有看看 https://github.com/django /django/blob/master/django/db/backends/sqlite3/base.py

I think the SQLite relational backend is quite simple if you're looking to go that road, maybe have a look https://github.com/django/django/blob/master/django/db/backends/sqlite3/base.py

这篇关于如何编写自定义django关系数据库后端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆