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