Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable use of generators without engine #323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kozlek
Copy link

@kozlek kozlek commented Apr 23, 2024

sqlacodegen is a great tool that does two things when used as cli:

  1. generate a MetaData object using SQLAlchemy built-in reflection
  2. generate code using the generated MetaData from step 1

While most of users use the CLI, the core value of sqlacodegen is the code generator.

This PR eases the standalone usage of the code generator by removing the need of an engine (and the associated driver). Actually, the engine+driver is only needed for the reflection (step 1), while a dialect is enough for step 2.

Example usage

from sqlacodegen.generators import DeclarativeGenerator
from sqlalchemy import Dialect
from sqlalchemy.dialects import postgresql

metadata = sa.MetaData()
generator = DeclarativeGenerator(metadata, dialect=postgresql.dialect(), options=set())
print(generator.generate())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant