自動產生符合Sqlachemy的Model: sqlautocode使用方式,codeblocks使用教程

來源:互聯網
上載者:User

自動產生符合Sqlachemy的Model: sqlautocode使用方式,codeblocks使用教程

調用格式如下:

sqlautocode <database_url> [options, ]

其中 database_url 就是我們使用 SQLAlchemy 時配置的資料庫 url,有的人也習慣稱之為 dsn。可選的參數如下:

-h, --help

顯示協助資訊

-o OUTPUT, --output=OUTPUT

要寫入的檔案,預設是 stdout

--force

覆蓋要寫入的檔案

-s SCHEMA, --schema=SCHEMA

選擇性參數,用於反向映射指定的資料庫

-t TABLES, --tables=TABLES

選擇性參數,是一個使用逗號隔開的列表,用於指定要反向工程的表名,支援 * 作為萬用字元,例如:

--tables account_*,orders,order_items,*_audit

-b TABLE_PREFIX, --table-prefix=TABLE_PREFIX

產生的 SQLAclhemy 表對象的首碼

-a TABLE_SUFFIX, --table-suffix=TABLE_SUFFIX

產生的 SQLAclhemy 表對象的尾碼

-i, --noindexes, --noindex

不產生索引資訊

-g, --generic-types

產生是使用符合 ANSI 標準的欄位類型而不是資料庫特定的類型

--encoding=ENCODING

輸出檔案使用的編碼,預設為 utf8

-e, --example

同時產生如何訪問資料的範例程式碼

-3, --z3c

產生用於 z3c.sqlalchemy 的代碼

-d, --declarative

產生使用 SQLAlchemy declarative 的代碼

-n, --interactive

在產生的程式碼包含互動樣本



example: sqlautocode mysql://user:password@host:port/datebase -o model_name.py -t table_name -e --force




聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.