我想调用一个多数据库Django安装上的存储过程,但没有任何运气得到结果。存储过程(位于辅助数据库中)始终返回Django中的空数组,但在mysql客户端中执行时会出现预期的结果。从SomeDBModel进口车型 从django.db进口连接Django调用第二个数据库上的存储过程
我view.py文件
def index(request, someid):
#Some related django-style query that works here
loc = getLocationPath(someid, 1)
print(loc)
def getLocationPath(id, someval):
cursor = connection.cursor()
cursor.callproc("SomeDB.spGetLocationPath", [id, someval])
results = cursor.fetchall()
cursor.close()
return results
我也曾尝试:
from SomeDBModel import models
from django.db import connections
def index(request, someid):
#Some related Django-style query that works here
loc = getLocationPath(someid, 1)
print(loc)
def getLocationPath(id, someval):
cursor = connections["SomeDB"].cursor()
<