Django教程:测试案例无法在Oracle Express数据库上创建testuser

时间:2019-09-16 07:47:57

标签: django oracle testcase

注意:我已经尝试过error: ORA-65096: invalid common user or role name in oracle

的解决方案

我正在阅读Django a link的教程。当我尝试使用“ py manage.py test民意测验”测试测试用例时,我得到了:

    C:\Users\user\Documents\user_django_projects\mysite>py manage.py test polls
    Creating test database for alias 'default'...
    Failed (ORA-01543: tablespace 'TEST_SYSTEM' already exists)
    It appears the test database, test_system, already exists. Type 'yes' to delete it, or 'no' to cancel: yes
    Destroying old test database for alias 'default'...
    Creating test user...
    Failed (ORA-65096: invalid common user or role name)
    Got an error creating the test user: ORA-65096: invalid common user or role name

django似乎无法在本地oracle Express数据库上创建临时用户。有人可以帮我解决吗?

1 个答案:

答案 0 :(得分:0)

以 sys 身份连接到 sqlplus

sqlplus "sys AS SYSDBA"

创建 PDB 帐户

SQL> alter session set container = XEPDB1;

Session altered.

SQL> create user djangousername identified by djangopassword;

User created.

SQL> grant all privileges to django;

Grant succeeded.

如果您使用 Oracle 12,请将 XEPDB1 更改为 ORCLPDB

现在您可以使用上面的用户名和密码使用 sqldeveloper 连接到数据库,并且 enter code hereService NameXEPDB1ORCLPDB

在 mysite/mysite/settings.py 更改您的数据库设置

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.oracle',
        'NAME': 'localhost:1521/XEPDB1',
        'USER': 'djangousername ',
        'PASSWORD': 'djangopassword',
    }
}

现在运行

python manage.py migrate
python manage.py test polls
相关问题