[Tutor] Truncating a Table
andreas at kostyrka.org
Fri May 11 17:59:47 CEST 2007
You either have autocommit enabled or you need to commit all data changes.
Can't tell the details as I'm not at my laptop :(
-- Ursprüngl. Mitteil. --
Betreff: Re: [Tutor] Truncating a Table
Von: "Leon Keylin" <ethics at gmail.com>
Datum: 11.05.2007 15:55
Thanks Tim for a fast reply.
The return gives me 0 Rows Truncated message and when I look at the table,
every record is still there.
There are no foreign keys on the table and no errors.
Andreas asked if I should commit after, should I? I didn't think I needed to
but I can try that.
On 5/11/07, Tim Golden <mail at timgolden.me.uk> wrote:
> Leon Keylin wrote:
> > Why would this not work?
> > import pymssql
> > con = pymssql.connect(host='server
> > name',user='username',password='pwd',database='Database')
> > cur = con.cursor()
> > query="TRUNCATE TABLE Consolidatedmsgs;"
> > cur.execute(query)
> > print "Table Truncated: %d rows deleted" % cur.rowcount
> > -----------
> > The return I get is that the program runs through but it doesn't
> > truncate the table.
> > The user that runs this has all the rights (read, write, truncate,
> > Any ideas? And yes, I am using a pymssql extension module.
> A couple of things, neither of which really answers
> your question. I wouldn't expect to get a cur.rowcount
> back from a TRUNCATE operation. And you don't need the
> semicolon at the end of the line. However, neither of
> those should prevent the truncation from occurring.
> Do you get an error? Or does the table still have rows
> in when you look? You can't, for example, truncate a
> table with active foreign keys. Does this same command
> work in Query Analyzer?
Tutor maillist - Tutor at python.org
More information about the Tutor