-
settings.py 配置
'default': {
'ENGINE': 'django.db.backends.oracle',
'NAME': 'SID', # 实例名,非service_name
'USER': '用户名',
'PASSWORD': '密码',
'HOST': 'IP',
'PORT': '端口',
}
-
安装cx-Oracle
pip3 install cx-Oracle==6.0 # 支持oracle11g的版本
-
反向从数据库表中生成model
py manage.py inspectdb models.py
-
inpectdb报错
The error was: ORA-00904: "IDENTITY_COLUMN": invalid identifier
### django1.11以上不支持oracle11g
pip3 uninstall django
TypeError: argument of type 'int' is not iterable
### 安装django1.11会报错,所以安装1.11.15版本解决
pip3 install django==1.11.15
AttributeError: 'cx_Oracle.Cursor' object has no attribute 'numbersAsStrings'
# lib\site-packages\django\db\backends\oracle\base.py 注释代码
self.cursor.numbersAsStrings = True
File "D:\Python38\lib\site-packages\django\contrib\admin\widgets.py", line 151
'%s=%s' % (k, v) for k, v in params.items(),
#找到D:\Python38\lib\site-packages\django\contrib\admin\widgets.py 文件第151行,将最后一个逗号删掉
'utf-8' codec can't decode bytes in position 82-83: invalid continuation byte
oracle、python、cx-oracle必须对应,64位python和cx-oracle也必须对应64位的oracle客户端