django.db.utils.DatabaseError: ORA-00933: SQL command not properly ended

django.db.utils.DatabaseError: ORA-00933: SQL command not properly ended

我正在尝试连接远程 oracle 数据库。我已经安装了客户端并将路径添加到 LD_LIBRARY_PATH.

生成的查询和参数如下。查询在 psqldbeaver 中运行。它仅在 运行 Django.

时失败
SELECT "AUTHTOKEN_TOKEN"."KEY", "AUTHTOKEN_TOKEN"."USER_ID", "AUTHTOKEN_TOKEN"."CREATED",  
"AUTH_USER"."ID", "AUTH_USER"."PASSWORD", "AUTH_USER"."LAST_LOGIN", "AUTH_USER"."IS_SUPERUSER",  
"AUTH_USER"."USERNAME", "AUTH_USER"."FIRST_NAME", "AUTH_USER"."LAST_NAME", "AUTH_USER"."EMAIL",  
"AUTH_USER"."IS_STAFF", "AUTH_USER"."IS_ACTIVE", "AUTH_USER"."DATE_JOINED" FROM "AUTHTOKEN_TOKEN" INNER  
 JOIN "AUTH_USER" ON ("AUTHTOKEN_TOKEN"."USER_ID" = "AUTH_USER"."ID") WHERE "AUTHTOKEN_TOKEN"."KEY" =  
:arg0 FETCH FIRST 21 ROWS ONLY   

{':arg0': <django.db.backends.oracle.base.OracleParam object at 0x10b8497d0>} 

我看到的错误是

Traceback (most recent call last):
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/views.py", line 497, in dispatch
    self.initial(request, *args, **kwargs)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/views.py", line 414, in initial
    self.perform_authentication(request)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/views.py", line 324, in perform_authentication
    request.user
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/request.py", line 227, in user
    self._authenticate()
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/request.py", line 380, in _authenticate
    user_auth_tuple = authenticator.authenticate(self)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/authentication.py", line 196, in authenticate
    return self.authenticate_credentials(token)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/rest_framework/authentication.py", line 201, in authenticate_credentials
    token = model.objects.select_related('user').get(key=key)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/models/query.py", line 425, in get
    num = len(clone)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/models/query.py", line 269, in __len__
    self._fetch_all()
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/models/query.py", line 1308, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/models/query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql
    cursor.execute(sql, params)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/backends/utils.py", line 99, in execute
    return super().execute(sql, params)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/kishorpawar/.virtualenvs/pl/lib/python3.7/site-packages/django/db/backends/oracle/base.py", line 535, in execute
    return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-00933: SQL command not properly ended

你能帮我看看这里有什么问题吗?

更新 1:
Oracle 版本为 Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

更新 2:
我安装了版本 11_2 的即时客户端库并将它们添加到 LD_LIBRARY_PATH.

我仍然面临这个问题

FETCH FIRST 21 ROWS ONLY 语法是 Oracle DB 12.1 中的新语法。

我建议您升级您的数据库,例如升级到 XE 18c https://www.oracle.com/database/technologies/xe-downloads.html