New to Python. Attempting to use pypyodbc to select data from a table in one Cache database, and inserting into a similarly configured table in another. Process works fine except for tables containing Date types. NULL values in date columns are handled without issue, but when data is present, insert fails with:
An error occurred: argument 7: TypeError: 'NoneType' object cannot be interpreted as an integer.
Source table:
CREATE TABLE "SAT"."AuditAttribute" (
"ID" INTEGER NOT NULL PRIMARY KEY DEFAULT $i(^SAT.AuditAttributeD),
"AddDelete" VARCHAR(50),
"ConstituentId" VARCHAR(50),
"CreatedDate" DATE,
"CreatedTime" TIME,
"DeleteDate" DATE,
"DeleteTime" TIME,
"FinderId" VARCHAR(50),
"Tag" VARCHAR(50),
"UserName" VARCHAR(50)
);
Target table:
CREATE TABLE "SAT_D3"."AuditAttribute_DWN" (
"DBase" VARCHAR(6),
"ID_OLD" INTEGER,
"AddDelete" VARCHAR(50),
"ConstituentId" VARCHAR(50),
"CreatedDate" DATE,
"CreatedTime" TIME,
"DeleteDate" DATE,
"DeleteTime" TIME,
"FinderId" VARCHAR(50),
"Tag" VARCHAR(50),
"UserName" VARCHAR(50)
)
;
select query:
select_query = 'select \'DWN\' as DBase, ID as "ID_OLD", AddDelete, ConstituentId, Tag, UserName, "CreatedDate" from SAT.AuditAttribute'
insert_query = 'insert into SAT_D3.AuditAttribute_DWN (DBase, "ID_OLD", AddDelete, ConstituentId, Tag, UserName, "CreatedDate") values (?,?,?,?,?,?,?)'
Displaying row[6[ for first failing row shows this: "datetime.date(2018, 6, 28)"
Have tried various methods, datetime.strftime(), datetime.strptime(), but haven't hit on the magic strategy. I assume it's something simple.
Thanks for your help!