Things to check first
Feature description
defaults to using stdout but the print statements above corrupt the stdout file by printing a bunch of logging statements
|
if args.version: |
|
print(version("sqlacodegen")) |
|
return |
|
|
|
if not args.url: |
|
print("You must supply a url\n", file=sys.stderr) |
|
parser.print_help() |
|
return |
|
|
|
if citext: |
|
print(f"Using sqlalchemy-citext {version('sqlalchemy-citext')}") |
|
|
|
if geoalchemy2: |
|
print(f"Using geoalchemy2 {version('geoalchemy2')}") |
|
|
|
if pgvector: |
|
print(f"Using pgvector {version('pgvector')}") |
|
|
|
# Use reflection to fill in the metadata |
|
engine_args = _parse_engine_args(args.engine_arg) |
|
engine = create_engine(args.url, **engine_args) |
|
metadata = MetaData() |
|
tables = args.tables.split(",") if args.tables else None |
|
schemas = args.schemas.split(",") if args.schemas else [None] |
|
options = set(args.options.split(",")) if args.options else set() |
|
|
|
# Instantiate the generator |
|
generator_class = generators[args.generator].load() |
|
generator = generator_class(metadata, engine, options) |
|
|
|
if not generator.views_supported: |
|
name = generator_class.__name__ |
|
print( |
|
f"VIEW models will not be generated when using the '{name}' generator", |
|
file=sys.stderr, |
|
) |
Instead, there should be a way to configure Logging to redirect the print statements to somewhere else (or suppress them altogether!)
Use case
sqlacodegen command which redirects stdout to a generated file (ex: from a docker exec command)
- Do anything which causes one of the
print statements to fire, like use pgvector.
Things to check first
Feature description
sqlacodegen/src/sqlacodegen/cli.py
Line 143 in 615d79c
sqlacodegen/src/sqlacodegen/cli.py
Lines 94 to 129 in 615d79c
Instead, there should be a way to configure Logging to redirect the
printstatements to somewhere else (or suppress them altogether!)Use case
sqlacodegencommand which redirects stdout to a generated file (ex: from a docker exec command)printstatements to fire, like use pgvector.