Use Sqlautocode to automatically generate SQLAlchemy ORM settings scripts

Source: Internet
Author: User

In my daily work, I like to use MySQL Workbench's data model tools to track and manage changes to the database and to generate the documentation needed for management. However, whenever the structure of the database changes slightly, it is also necessary to modify the ORM settings script written using SQLAlchemy. While using Sqlsoup, you can use the primary functionality of SQLAlchemy without configuring ORM, but is it possible to automatically generate scripts from existing databases? Search the internet for a bit, found the utility called Sqlautocode. Simply execute the sqlautocode command on the command line to automatically generate code based on the parameters!

Its invocation format is as follows:

Sqlautocode <database_url> [Options,]

 database_url   is the database we configured when we use SQLAlchemy   url , some people also used to call it  

-H,--help

Display Help information

-O OUTPUT,--output=output

The file to be written by default is stdout

--force

Overwrite the file to be written

-S SCHEMA,--schema=schema

Optional parameters to reverse map the specified database

-T TABLES,--tables=tables

Optional parameter, a comma-separated list that specifies the name of the table to reverse-engineer, supporting * as a wildcard character, for example:

--tables Account_*,orders,order_items,*_audit

-B table_prefix,--table-prefix=table_prefix

The prefix of the generated Sqlaclhemy Table object

-A table_suffix,--table-suffix=table_suffix

The suffix of the generated Sqlaclhemy Table object

-I.,--noindexes,--noindex

Do not generate index information

-G,--generic-types

Build is using ANSI-compliant field types instead of database-specific types

--encoding=encoding

The encoding used by the output file, which defaults to UTF8

-E,--example

Sample code to generate access to data at the same time

-3,--z3c

Generate code for Z3c.sqlalchemy

-D,--declarative

Generate code that uses SQLAlchemy declarative

-N,--interactive

The generated code contains an interactive example


Use Sqlautocode to automatically generate SQLAlchemy ORM settings scripts

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.