-
Notifications
You must be signed in to change notification settings - Fork 3
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
Comments
That seems like a bug, possibly provoked by reusing an existing bcp
connection object. Try doing the context object within the for loop and see
if it makes a difference. In the meantime, I'll try to reproduce in Python
2 and Python 3
…On Fri, Mar 13, 2020 at 2:27 PM Grzegorz Chilczuk ***@***.***> wrote:
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:
@contextmanagerdef 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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAQRXFDPTRLXB3CUETWIUWDRHJUHTANCNFSM4LHHAKQQ>
.
|
Also, what are the TDS and SQL Server versions? |
Freetds:
SQL Server: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
Final result in database is:
Everything works as it should when I make a reconnection after each commit.
The text was updated successfully, but these errors were encountered: