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

feat: Use SQLAlchemy core objects where possible and append only added #138

Merged
merged 17 commits into from
Jun 15, 2023

Conversation

visch
Copy link
Member

@visch visch commented Jun 7, 2023

Closes #121, #22, #64, #119, #21, #54

@visch visch changed the title feat: Initial table creation using sql alchemy and tests passing feat: Use SQLAlchemy core objects where possible Jun 7, 2023
@visch visch marked this pull request as ready for review June 8, 2023 01:13
@visch visch self-assigned this Jun 8, 2023
@visch visch requested a review from edgarrmondragon June 8, 2023 01:14
@visch
Copy link
Member Author

visch commented Jun 8, 2023

This ended up solving more issues than I thought it would. Added them to the main list, just wanted to call it out :)

new_table = sqlalchemy.Table(new_table_name, metadata, *new_columns)
new_table.create(bind=connection)
select = sqlalchemy.sql.select(table.columns)
insert = Insert(new_table).from_select(names=table.columns, select=select)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major bug here, we only want to clone the metadata of the table. Might be easier to just not worry about the clone step here, and just create a temp table

@pnadolny13 pnadolny13 requested review from kgpayne and pnadolny13 June 8, 2023 18:55
@visch
Copy link
Member Author

visch commented Jun 8, 2023

Added append only as well

@visch visch changed the title feat: Use SQLAlchemy core objects where possible feat: Use SQLAlchemy core objects where possible and append only added Jun 8, 2023
…as easier than making tests for the default public schema, if instead we just make this be set to something.
@pnadolny13
Copy link

@visch I like where this PR is headed, leveraging sqlalchemy for as much as possible is probably a good idea. I've run into a few things while working on target-snowflake that would have benefitted from using sqlalchemy instead of building queries ourseleves.

I didnt see anything worth commenting on from a quick review. I see tests aren't passing yet so feel free to @ me again once this is ready for a final full review.

@visch
Copy link
Member Author

visch commented Jun 9, 2023

@visch I like where this PR is headed, leveraging sqlalchemy for as much as possible is probably a good idea. I've run into a few things while working on target-snowflake that would have benefitted from using sqlalchemy instead of building queries ourseleves.

I didnt see anything worth commenting on from a quick review. I see tests aren't passing yet so feel free to @ me again once this is ready for a final full review.

Thanks for taking a quick peak! Sorry about the failure, I missed it after I pushed this up (The tests do pass on Python 3.8+). Fixed it for Python 3.7 and added an issue here for Python 3.7 #141

As I say that another test fails :/ , fixing it now.

@visch
Copy link
Member Author

visch commented Jun 9, 2023

@visch I like where this PR is headed, leveraging sqlalchemy for as much as possible is probably a good idea. I've run into a few things while working on target-snowflake that would have benefitted from using sqlalchemy instead of building queries ourseleves.

I didnt see anything worth commenting on from a quick review. I see tests aren't passing yet so feel free to @ me again once this is ready for a final full review.

Ok they are fixed now @pnadolny13

Copy link

@pnadolny13 pnadolny13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@visch this looks good to me!

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

Successfully merging this pull request may close these issues.

Use SQLAlchemy Table/Column Objects - Names of Tables / Columns
2 participants