mkleehammer / pyodbc

Python ODBC bridge
https://github.com/mkleehammer/pyodbc/wiki
MIT No Attribution
2.92k stars 561 forks source link

how to print result of create table? #1144

Closed Saleem344 closed 1 year ago

Saleem344 commented 1 year ago

I have dynamic table creation and I would like to see the table creation result.

when I print rowcount it is always "-1".

this is my code:

 result  = self.cursor.execute("IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='cm_4g_lte_acbpr' and xtype='U') CREATE TABLE cm_4g_lte_acbpr ( id varchar(100), mrbts varchar(100), lnbts, acbpr varchar(100), parent varchar(100), distname varchar(100), class varchar(100), version varchar(100), operation varchar(100), acbarskipformmtelvideo varchar(100), acbarskipformmtelvoice varchar(100), acbarskipforsms varchar(100), cellreshoblockplmnacbmax varchar(100), ecallacbarredauto varchar(100), emerhoblockplmnacbmax varchar(100), hoblockplmnacbmaxonly varchar(100), client varchar(100), nhgalias varchar(100), ndacdefault varchar(100), extractiondatetime varchar(100), timestamp varchar(100));")

 print(result.rowcount)

Can anyone help ?

Thanks.

gordthompson commented 1 year ago

What sort of "result" would you expect to see? DDL statements don't return a result per se; they return nothing if they succeed and return an error if they fail.