-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
73b3fea
commit d8a4dc9
Showing
5 changed files
with
2,143 additions
and
862 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
from alembic import op | ||
from sqlalchemy import engine_from_config | ||
from sqlalchemy.engine import reflection | ||
|
||
|
||
|
||
def table_does_not_exist(table, schema=None): | ||
config = op.get_context().config | ||
engine = engine_from_config( | ||
config.get_section(config.config_ini_section), prefix='sqlalchemy.') | ||
config.get_section(config.config_ini_section), prefix="sqlalchemy." | ||
) | ||
insp = reflection.Inspector.from_engine(engine) | ||
return insp.has_table(table, schema) == False | ||
return insp.has_table(table, schema) is False | ||
|
||
|
||
def table_has_column(table, column): | ||
config = op.get_context().config | ||
engine = engine_from_config( | ||
config.get_section(config.config_ini_section), prefix='sqlalchemy.') | ||
config.get_section(config.config_ini_section), prefix="sqlalchemy." | ||
) | ||
insp = reflection.Inspector.from_engine(engine) | ||
has_column = False | ||
for col in insp.get_columns(table): | ||
if column not in col['name']: | ||
if column not in col["name"]: | ||
continue | ||
has_column = True | ||
return has_column | ||
return has_column |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.