官方文档
https://eco.dameng.com/document/dm/zh-cn/start/python-development.html
Django适配达梦
https://blog.csdn.net/qq_35349982/article/details/132165581
https://blog.csdn.net/weixin_61894388/article/details/126330168
项目适配达梦
- 升级或安装依赖
Django==3.1.7
django-dmPython==3.1.7
dmPython==2.5.5
- 更改所有的model文件把
db_table = 'ROLE'
小写改成大写 - 修改连接数据库方式
# 达梦数据库
DATABASES = {
'default': {
'ENGINE': 'django_dmPython',
'NAME': 'dm8_test',
'USER': 'SYSDBA',
'PASSWORD': 'SYSDBA001',
'HOST': '127.0.0.1',
'PORT': '5236',
}
}
命令
https://www.modb.pro/db/237497
https://blog.51cto.com/u_7548043/5464097
https://www.cnblogs.com/zdstudy/p/16550878.html
https://blog.csdn.net/Dyeln/article/details/125877919
http://www.floverow.com/index.php?id=725
https://blog.csdn.net/hongweigg/article/details/92621952
部署达梦数据库/启动
命令解析:https://blog.csdn.net/Januea/article/details/134240787
docker run -d -p 30236:5236 --restart=always --name dm8_test --privileged=true -e PAGE_SIZE=16 -e LD_LIBRARY_PATH=/opt/dmdbms/bin -e EXTENT_SIZE=32 -e BLANK_PAD_MODE=1 -e LOG_SIZE=1024 -e UNICODE_FLAG=1 -e LENGTH_IN_CHAR=1 -e INSTANCE_NAME=dm8_test -v /data/dm8_test:/opt/dmdbms/data dm8_single:dm8_20230808_rev197096_x86_rh6_64
python manage.py makemigrations accounts application commons mssa report upgrade
python manage.py migrate
python3 manage.py shell -c "from django.contrib.auth.models import User; User.objects.create_superuser('[email protected]', '[email protected]', 'Admin123')"
基础命令
# 链接 SYSDBA是默认用户名 SYSDBA001是默认密码
/opt/dmdbms/bin/disql SYSDBA/SYSDBA001
#查看表结构
SELECT DBMS_METADATA.GET_DDL('TABLE','table_name') FROM dual;
问题汇总
-
插入数据时,报错
DatabaseError: [CODE:-2111]
(dmdbms) tjw@tjw-ThinkPad-P15v-Gen-1:/var/www/rc-platform$ python manage.py migrate
Operations to perform:
Apply all migrations: accounts, admin, application, auth, commons, contenttypes, mssa, report, sessions, upgrade
Running migrations:
Applying auth.0003_alter_user_email_max_length...Traceback (most recent call last):
File "/home/tjw/.virtualenvs/dmdbms/lib/python3.8/site-packages/django/db/backends/utils.py", line 82, in _execute
return self.cursor.execute(sql)
File "/home/tjw/.virtualenvs/dmdbms/lib/python3.8/site-packages/django_dmPython/base.py", line 439, in execute
return self.cursor.execute(query, args)
dmPython.DatabaseError: [CODE:-2111]第1 行附近出现错误:
无效的列名[AAAAAAAAAAAAAAAAAO]
解决方式
修改源码,位置django_dmPython/operations.py
query = """select %s from %s where rowid = '%s'""" %(self.quote_name(pk_name), self.quote_name(table_name), cursor.lastrowid
借鉴:https://blog.csdn.net/m0_69072302/article/details/128836334
-
无效的列名[WTKJE]
解决方式
# 把model.py 的db_table由小写改成大写即可
class Meta:
db_table = 'ROLE'
-
dmPython.IntegrityError: [CODE:-6609]违反列[LAST_LOGIN]非空约束
解决方式:使用sql把字段改成去掉约束
ALTER TABLE AUTH_USER MODIFY LAST_LOGIN NULL;
标签:name,Python,适配,py,Django,blog,https,dm8,dmPython From: https://www.cnblogs.com/tjw-bk/p/18034282