简体   繁体   中英

IBM Cloud db2 django migrations python manage.py migrate

Created my first ibm db2 database on ibm cloud and connected it with 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. Even for session and content types.

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.

My question is how can I give myself (admin account) privileges so that my python manage.py migrate does'nt throw an error.

Or there is something wrong I am doing in django app itself. (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. There are other restrictions when using the LITE plan that follow from being a multi-tenanted solution. 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.

But it is easier to use the Db2 communinty edition for development anyway because you get all the control that you need.

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. 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. But as stated earlier, you are likely to then run into other restrictions of the LITE plan.

In short: use the free community edition or pay to get the required access.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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