[Python] ADODB, Sqlserver e None

piergiorgio pancino piertoni a yahoo.it
Mer 6 Nov 2013 08:53:01 CET


Ciao a tutti!
Ho un piccolo problema nell'esecuzione di una query sql (sqlserver) tramite win32com.client ADODB.
Fondamentalmente mi da l'errore "Il nome di colonna 'None' non è valido" e non capisco perché non gli vada bene passargli None come valore nullo.
Forse è un problema della funzione format che uso? Dovrei usare il classico sistema "%s %s" %(var1,var2) ?

Stringa di creazione della Query:
query=     "INSERT INTO  dbo.IM_WorkingReports " \
                        "VALUES ( {r.WorkingReportId}, {r.WorkingReportNo}, {r.WorkingReportDate}, {r.PostingDate}, {r.Customer}, '{r.Payment}', {r.PostedToAccounting}, {r.Issued}, {r.Posted}, {r.Printed}, " \

                        "{r.InvoiceFollows}, '{r.WRReason}', '{r.StubBook}', {r.Job}, {r.PostedToCostAccounting}, {r.WorkingReportType}, {r.LabourHourlyRate}, {r.CallServiceCost}, {r.DNId}, {r.DNNo}, " \
                        "{r.PriceList}, {r.CustomerBank}, {r.CompanyBank}, {r.AccTpl}, {r.TaxJournal}, {r.CallService}, {r.Labour}, {r.Description}, {r.InvRsn}, {r.StorageStubBook}, {r.StoragePhase1}," \
                        "{r.StoragePhase2}, {r.SpecificatorPhase1}, {r.SpecificatorPhase2}, {r.SaleDocGenerated}, {r.PostedToInventory}, {r.EntryId}, {r.BalanceFromEmployeesTab}, {r.BalanceFromActualitiesTab}, " \
                        "{r.Currency}, {r.FixingDate}, {r.Fixing}, {r.FixingIsManual}, {r.WorkingReportTypology}, {r.Employee}, {r.Qualification}, {r.ExternalReference}, " \
                        "'{r.TBCreated}', '{r.TBModified}', {r.TBCreatedID}, {r.TBModifiedID} );".format(r=record)

record è un oggetto i cui metodi vengono riempiti e poi passati alla query

Query:
INSERT INTO  dbo.IM_WorkingReports ( WorkingReportId, WorkingReportNo, WorkingReportDate, PostingDate, Customer, Payment, PostedToAccounting, Issued, Posted, Printed, InvoiceFollows, WRReason, StubBook, Job, PostedToCostAccounting, WorkingReportType, LabourHourlyRate, CallServiceCost, DNId, DNNo, PriceList, CustomerBank, CompanyBank, AccTpl, TaxJournal, CallService, Labour, Description, InvRsn, StorageStubBook, StoragePhase1,StoragePhase2, SpecificatorPhase1, SpecificatorPhase2, SaleDocGenerated, PostedToInventory, EntryId, BalanceFromEmployeesTab, BalanceFromActualitiesTab, Currency, FixingDate, Fixing, FixingIsManual, WorkingReportTypology, Employee, Qualification, ExternalReference, TBCreated, TBModified, TBCreatedID, TBModifiedID) VALUES ( 6775, 5022, 20131014, 2013-11-06, 0046, 'R601-10', 0, 1, 1, 0, 1, 'ECO', 'PR', 12/00006, 0, 65536001, 0, 0, 0, None, None, 02008-61840, 01, FE, VEN, None, None, None, I-CIRAP, None, SEDE,None, None, None, 0, 1,
 4069, 1, 1, None, -36523, 0, 0, 19333120, None, None, None, '2013-11-06 07:49:48+00:00', '2013-11-06 07:49:48+00:00', 2, 2 ); 
Eccezione:
 (-2147352567, 'Eccezione.', (0, 'Microsoft OLE DB Provider for ODBC Drivers', "[Microsoft][ODBC SQL Server Driver][SQL Server]Il nome di colonna 'None' non è valido.", None, 0, -2147217900), None)

Grazie per l'aiuto
Piergiorgio
-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20131106/acd5570a/attachment-0001.html>


Maggiori informazioni sulla lista Python