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

The field names should be presented. #240

Open
ibardarov-reptrak opened this issue Oct 23, 2024 · 0 comments
Open

The field names should be presented. #240

ibardarov-reptrak opened this issue Oct 23, 2024 · 0 comments

Comments

@ibardarov-reptrak
Copy link

ibardarov-reptrak commented Oct 23, 2024

The generated sql code for insert do not point the field names.

Then the only way to make it work is to order the field names in the dataframe.

        if not self.__is_valid_table(table):
            raise InterfaceError("Invalid table name passed to write_dataframe: {}".format(table))
        sanitized_table_name: str = self.__sanitize_str(table)
        arrays: list = df.values.tolist()
        placeholder: str = ", ".join(["%s"] * len(arrays[0]))
        sql: str = "insert into {table} values ({placeholder})".format(
            table=sanitized_table_name, placeholder=placeholder
        )

https://github.com/aws/amazon-redshift-python-driver/blob/64cbd54ef6a5e71d98ce193630d09267cc154379/redshift_connector/cursor.py#L584C1-L591C10

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

No branches or pull requests

1 participant