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

Bulk insert fails when computed field in table #2

Open
markweissman opened this issue Sep 14, 2022 · 1 comment
Open

Bulk insert fails when computed field in table #2

markweissman opened this issue Sep 14, 2022 · 1 comment

Comments

@markweissman
Copy link

I'm trying to bulk insert into a table that had a computed column, particularly:

create TABLE [dbo].[tstBCPComputedColumn] (
Id int not null identity(1,1) UNIQUE,
Code varchar(4096) not null,
Format varchar(10) not null default 'xml',
Hash
AS CAST(hashbytes('SHA1',[Code]) AS VARBINARY(20))
PERSISTED NOT NULL,
DateInserted DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CreatedBy varchar(30) NOT NULL DEFAULT CURRENT_USER,
CONSTRAINT pk_enumTestBCPComputedColumn PRIMARY KEY(Id))

I'm using

conn.bulk_insert(table, batch, batch_size=batch_size)

from ctds and providing all columns. If I remove the Hash column from the table, it works well.
With that column,

_tds.ProgrammingError: ('unrecognized msgno', 'query', 'BCP [BOS-DBRESEARCH01].mweissman.dbo.tstBCPComputedColumn', 'params', 'None', 'connection', 'DRIVER={FreeTDS};TDS_Version=8.0;ClientCharSet=ISO8859-1;SERVER=BOS-DBRESEARCH01;PORT=1433;VAULT_NAME=db-research01;DATABASE=master', 'type', 'ProgrammingError')

I've tried passing in:

  • 0
  • b''
  • None
  • leaving out the Hash column from batch
  • passing dictionaries without Hash

but none of those work. Is this supported? Can you provide some advice on how to insert into this table?

This works with pymssql btw but I need kerberos support which only ctds has.

Thanks, Mark Weissman

@HuangRicky
Copy link
Owner

HuangRicky commented Sep 14, 2022 via email

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