Import a textfile to MS SQL with python

Tim Golden tim.golden at viacom-outdoor.co.uk
Wed Sep 6 06:49:58 EDT 2006


[joel.sjoo at gmail.com]

| Traceback (most recent call last):
| File "txttosql6.py", line 23, in ?
|     row
| File "C:\Python24\Lib\site-packages\pymssql.py", line 120, in execute
|     self.executemany(operation, (params,))
| File "C:\Python24\Lib\site-packages\pymssql.py", line 146, in
| executemany
|     raise DatabaseError, "internal error: %s (%s)" %
| (self.__source.errmsg(), se
| lf.__source.stdmsg())
| pymssql.DatabaseError: internal error: None (None)

Are you calling .execute or .executemany? Your code below
has .execute, but the traceback is coming from .executemany.
If you're using the latter, you need to pass the whole list
at once:

.
.
.
mycursor = myconn.cursor()
# omit: for row in data:
mycursor.executemany (
  "INSERT INTO python (id, namn, efternamn) VALUES (?, ?, ?)",
  data
)

If that's not the problem, I can't easily see what it is.
I don't usually use pymssql, but I do have it installed,
so if I get a chance later, I'll give it a go.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list