Automatically generate a Model that complies with Sqlachemy: How to Use sqlautocode. How to Use codeblocks

Source: Internet
Author: User

Automatically generate a Model that complies with Sqlachemy: How to Use sqlautocode. How to Use codeblocks

The call format is as follows:

sqlautocode <database_url> [options, ]

Database_url is the database url we configured when using SQLAlchemy. Some people are also used to calling it dsn. Optional parameters:

-H, -- help

Show Help Information

-O OUTPUT, -- output = OUTPUT

The file to be written. The default value is stdout.

-- Force

Overwrite the file to be written

-S SCHEMA, -- schema = SCHEMA

Optional parameter, used for reverse ing of the specified database

-T TABLES, -- tables = TABLES

An optional parameter, which is a list separated by commas (,). It is used to specify the name of the table to be reverse engineered. * can be used as a wildcard. For example:

-- Tables account _ *, orders, order_items, * _ audit

-B TABLE_PREFIX, -- table-prefix = TABLE_PREFIX

Prefix of the generated SQLAclhemy table object

-A TABLE_SUFFIX, -- table-suffix = TABLE_SUFFIX

Suffix of the generated SQLAclhemy table object

-I, -- noindexes, -- noindex

No index information is generated

-G, -- generic-types

Generate a field that complies with ANSI standards rather than a database-specific type.

-- Encoding = ENCODING

The encoding used by the output file. The default value is utf8.

-E, -- example

Generate sample code for data access at the same time

-3, -- z3c

Generate code for z3c. sqlalchemy

-D, -- declarative

Generate code using SQLAlchemy declarative

-N, -- interactive

Contains interaction examples in the generated code



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




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.