亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

解決django migrate報錯的方法

發布時間:2020-07-03 09:09:47 來源:億速云 閱讀:478 作者:清晨 欄目:開發技術

不懂解決django migrate報錯的方法?其實想解決這個問題也不難,下面讓小編帶著大家一起學習怎么去解決,希望大家閱讀完這篇文章后大所收獲。

錯誤信息

解決django migrate報錯的方法

PS D:\parttime\python\django\guanxiangzhiji> python manage.py migrate
Operations to perform:
 Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Traceback (most recent call last):
 File "D:\app\anaconda\lib\site-packages\django\db\backends\utils.py", line 82, in _execute
 return self.cursor.execute(sql)
 File "D:\app\anaconda\lib\site-packages\django\db\backends\oracle\base.py", line 510, in execute
 return self.cursor.execute(query, self._param_generator(params))
cx_Oracle.DatabaseError: ORA-02000: missing ALWAYS keyword

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
 File "D:\app\anaconda\lib\site-packages\django\db\migrations\recorder.py", line 67, in ensure_schema
 editor.create_model(self.Migration)
 File "D:\app\anaconda\lib\site-packages\django\db\backends\base\schema.py", line 307, in create_model
 self.execute(sql, params or None)
 File "D:\app\anaconda\lib\site-packages\django\db\backends\base\schema.py", line 137, in execute
 cursor.execute(sql, params)
 File "D:\app\anaconda\lib\site-packages\django\db\backends\utils.py", line 99, in execute
 return super().execute(sql, params)
 File "D:\app\anaconda\lib\site-packages\django\db\backends\utils.py", line 67, in execute
 return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
 File "D:\app\anaconda\lib\site-packages\django\db\backends\utils.py", line 76, in _execute_with_wrappers
 return executor(sql, params, many, context)
 File "D:\app\anaconda\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
 return self.cursor.execute(sql, params)
 File "D:\app\anaconda\lib\site-packages\django\db\utils.py", line 89, in __exit__
 raise dj_exc_value.with_traceback(traceback) from exc_value
 File "D:\app\anaconda\lib\site-packages\django\db\backends\utils.py", line 82, in _execute
 return self.cursor.execute(sql)
 File "D:\app\anaconda\lib\site-packages\django\db\backends\oracle\base.py", line 510, in execute
 return self.cursor.execute(query, self._param_generator(params))
django.db.utils.DatabaseError: ORA-02000: missing ALWAYS keyword

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
 File "manage.py", line 21, in <module>
 main()
 File "manage.py", line 17, in main
 execute_from_command_line(sys.argv)
 File "D:\app\anaconda\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
 utility.execute()
 File "D:\app\anaconda\lib\site-packages\django\core\management\__init__.py", line 375, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
 File "D:\app\anaconda\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
 self.execute(*args, **cmd_options)
 File "D:\app\anaconda\lib\site-packages\django\core\management\base.py", line 364, in execute
 output = self.handle(*args, **options)
 File "D:\app\anaconda\lib\site-packages\django\core\management\base.py", line 83, in wrapped
 res = handle_func(*args, **kwargs)
 File "D:\app\anaconda\lib\site-packages\django\core\management\commands\migrate.py", line 234, in handle
 fake_initial=fake_initial,
 File "D:\app\anaconda\lib\site-packages\django\db\migrations\executor.py", line 91, in migrate
 self.recorder.ensure_schema()
 File "D:\app\anaconda\lib\site-packages\django\db\migrations\recorder.py", line 69, in ensure_schema
 raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (ORA-02000: missing ALWAYS keyword)

環境情況

1、操作系統:Win10 64bit

解決django migrate報錯的方法

2、Python版本:3.7.3

解決django migrate報錯的方法

3、django版本:2.2.4

解決django migrate報錯的方法

4、Oracle版本:11.2.0.4

解決django migrate報錯的方法

5、cx_oracle版本:7.0.0

解決django migrate報錯的方法

6、settings配置

解決django migrate報錯的方法

原因分析

從錯誤提示ORA-02000: missing ALWAYS keyword看,是SQL語法錯誤,創建表的時候使用了Always這個關鍵詞。 Always是在Oracle12c的新特性自增序列里用到的,語法如下:

generated-column-spec
[ GENERATED { ALWAYS | BY DEFAULT } AS IDENTITY 
[ ( START WITH IntegerConstant 
[ ,INCREMENT BY IntegerConstant] ) ] ] ]

但是,我機器上用的是Oracle11.2.0.4版本,這個語法在11g版本里執行自然就會報ORA-02000的錯誤。

解決方案

看了網上的一些解決方案,主要有2種:

(1)將Oracle升級到12c

(2)將cx_oracle降低版本

剛開始選用方案(2),覺得簡單,但是實際操作下來,問題一環套一環,比如說將cx_oracle降低版本后,接著出現了django版本與cx_oracle版本不適應的情況,接著又降低django版本。。。接著做還是不行,最終放棄了。不知道有沒有人成功過。

重新選擇方案(1),裝了Oracle12.1.0.2

解決django migrate報錯的方法

再將django和cx_oracle升級回最新版本,migrate的時候就成功了

解決django migrate報錯的方法

感謝你能夠認真閱讀完這篇文章,希望小編分享解決django migrate報錯的方法內容對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,遇到問題就找億速云,詳細的解決方法等著你來學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

大厂| 灵寿县| 达拉特旗| 宁波市| 徐水县| 崇阳县| 涿州市| 苏尼特右旗| 河北区| 磴口县| 根河市| 清苑县| 东兰县| 亳州市| 南郑县| 汨罗市| 宝清县| 子洲县| 平潭县| 高要市| 金华市| 青川县| 友谊县| 南召县| 江华| 通辽市| 封丘县| 万源市| 永昌县| 岳西县| 永安市| 界首市| 呼伦贝尔市| 虞城县| 清流县| 芜湖县| 香河县| 六盘水市| 洱源县| 栾川县| 东辽县|