Import a textfile to MS SQL with python

Tim Golden tim.golden at
Wed Sep 6 12:49:58 CEST 2006

[joel.sjoo at]

| Traceback (most recent call last):
| File "", line 23, in ?
|     row
| File "C:\Python24\Lib\site-packages\", line 120, in execute
|     self.executemany(operation, (params,))
| File "C:\Python24\Lib\site-packages\", 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 (?, ?, ?)",

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.


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:

More information about the Python-list mailing list