简体   繁体   English

IBM Cloud db2 django 迁移 python manage.py migrate

[英]IBM Cloud db2 django migrations python manage.py migrate

Created my first ibm db2 database on ibm cloud and connected it with django.在 ibm 云上创建了我的第一个 ibm db2 数据库,并将其与 django 连接。 With following settings:使用以下设置:

 'default':{
        'ENGINE'     : 'ibm_db_django',
         'NAME'       : 'BLUDB',
         'USER'       : 'xxxxxxxxxxxxxxxx',
         'PASSWORD'   : 'xxxxxxxxxxxxxxxx',
         'HOST'       : 'dashdb-xxxxxxx-sbox-xxxxxxxxxx.services.eu-gb.bluemix.net',
         'PORT'       : '50000',
         'PCONNECT'   :  True,
    }

Connection works very well because I can run migrations for custom django app which I added.连接工作得很好,因为我可以为我添加的自定义 django 应用程序运行迁移。 Even for session and content types.即使是 session 和内容类型。

Problems arises due while running migrations for auth and admin.运行身份验证和管理员迁移时出现问题。 I get following error message:我收到以下错误消息:

Exception('SQLNumResultCols failed: [IBM][CLI Driver][DB2/LINUXX8664] SQL0551N  The statement failed because the authorization ID does not have the required authorization or privilege to perform the operation.  Authorization ID: "XXXXXXXX".  Operation: "SELECT". Object: "SYSIBMADM.ADMINTABINFO".  SQLSTATE=42501 SQLCODE=-551'

I understand that I dont have privileges to perform select operation on SYSIBMADM.ADMINTABINFO.我了解我没有权限对 SYSIBMADM.ADMINTABINFO 执行 select 操作。

My question is how can I give myself (admin account) privileges so that my python manage.py migrate does'nt throw an error.我的问题是如何给自己(管理员帐户)权限,以便我的 python manage.py migrate 不会引发错误。

Or there is something wrong I am doing in django app itself.或者我在 django 应用程序本身中做错了什么。 (INITIAL MIGRATIONS) (初始迁移)

As you are using the LITE plan (free), you don't get any access currently to SYSIBMADM.ADMINTABINFO on the IBM Db2-on-cloud.由于您使用的是 LITE 计划(免费),因此您目前无法访问 IBM Db2-on-cloud 上的SYSIBMADM.ADMINTABINFO There are other restrictions when using the LITE plan that follow from being a multi-tenanted solution.作为多租户解决方案,使用 LITE 计划时还有其他限制。 And while you might workaround one restriction, you will quickly find another restriction.虽然您可能会解决一个限制,但您会很快找到另一个限制。

Your options include developing with the local (either non-docker or dockerized) Db2 community edition, before using a $$paid$$ version of Db2-on-cloud that gives you the required access.您的选择包括使用本地(非 docker 或 dockerized)Db2 社区版进行开发,然后再使用为您提供所需访问权限的 Db2-on-cloud 的 $$paid$$ 版本。

But it is easier to use the Db2 communinty edition for development anyway because you get all the control that you need.但无论如何,使用 Db2 社区版进行开发更容易,因为您可以获得所需的所有控制权。

Another workaround, as ibm_db_django is open source, you may also be able to modify that code to not use the restricted objects, in case a newer version of django has not already done it.另一种解决方法是,由于 ibm_db_django 是开源的,您也可以修改该代码以不使用受限对象,以防 django 的较新版本尚未完成。 For example, the reason that ibm_db_django references sysibmam.admintabinfo is to determine whether a reorg is required after running ALTER TABLE statements, but you could ( for development purposes only ) alter that check.例如,ibm_db_django 引用sysibmam.admintabinfo的原因是确定在运行ALTER TABLE语句后是否需要重组,但您可以(仅出于开发目的)更改该检查。 But as stated earlier, you are likely to then run into other restrictions of the LITE plan.但如前所述,您可能会遇到 LITE 计划的其他限制。

In short: use the free community edition or pay to get the required access.简而言之:使用免费的社区版或付费获得所需的访问权限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM