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

Malformed data being sent to the database #2

Open
gchilczuk opened this issue Mar 13, 2020 · 3 comments
Open

Malformed data being sent to the database #2

gchilczuk opened this issue Mar 13, 2020 · 3 comments

Comments

@gchilczuk
Copy link

I'm not sure how much it's a bug and how much some kind of "undocumented behavior".
environment: CentOS 7, Python 3.7.7, package installed with pip install .
My code:

@contextmanager
def connection():
    bcp_connection = bcp.Connection(
        server="*", username="*", password="*", database="*", batchsize=16,
    )
    yield bcp_connection
    bcp_connection.disconnect()


def main():
    datasets = [
        [[1, 1], [2, 2]],
        [[5, 5], [6, 6]],
        [[1, 1], [2, 2]]  # this should cause a PK conflict
    ]
    with connection() as bcp_connection:
        for data in datasets:
            bcp_connection.init(TABLE)
            for row in data:
                bcp_connection.send(row)
            bcp_connection.commit()


if __name__ == "__main__":
    main()

Final result in database is:

1		1
2		2
35848246	35848246
1726742581	1726742581
35848242	35848242
1726742577	1726742577

Everything works as it should when I make a reconnection after each commit.

@gchilczuk gchilczuk changed the title Malformed data beeing send to database Malformed data being sent to the database Mar 13, 2020
@damionw
Copy link
Owner

damionw commented Mar 13, 2020 via email

@damionw
Copy link
Owner

damionw commented Mar 13, 2020

Also, what are the TDS and SQL Server versions?

@gchilczuk
Copy link
Author

Freetds:

freetds.x86_64                         1.1.20-1.el7                    @epel    
freetds-devel.x86_64                   1.1.20-1.el7                    @epel    
freetds-libs.x86_64                    1.1.20-1.el7                    @epel    

SQL Server:
Microsoft SQL Server 2016 (SP2-CU11-GDR) (KB4535706) - 13.0.5622.0 (X64)

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

2 participants