0

I'm trying to read an XML file from a web address and write that file to a Sql Server DB as an XML data-type. I don't want to do any parsing of the XML, just write it like a string to the database. I will be using it to take snapshots every few hours and then use Sql to deal with the information as an XML datatype.

I'm currently receiving below mentioned error:

'IOError: [Errno socket error] [Errno 11001] getaddrinfo failed'  

I'm not sure I'm reading the xml file properly (as one single piece of information) - Any suggestions?

import pyodbc
import urllib
xmlpath = "http://www.w3schools.com/xml/cd_catalog.xml"
xmlurl= urllib.urlopen(xmlpath)
xml_as_string = xmlurl.read()


cnxn = pyodbc.connect(
    'Trusted_Connection=yes; 
    DRIVER={SQL Server};
    SERVER=servername; 
    DATABASE=database_name; 
    UID=user; 
    PWD=pass'
) 
cursor = cnxn.cursor()
cursor.execute("insert into table values ('Text', 1, '"+ xml_as_string +"')") 
cnxn.commit()
3
  • Try to use urllib2 instead urllib Commented Feb 13, 2013 at 16:20
  • Instead of posting only the last error, please post the full stack trace. Commented Feb 13, 2013 at 17:11
  • This is a sign of issues with your network, specifically your DNS and has nothing to do with the code you have written. Check if you are able to resolve the domain from the command line (ie, by using nslookup or dig). Commented Feb 27, 2014 at 8:05

1 Answer 1

1

The [Errno 11001] getaddrinfo failed suggests that you're facing some DNS problems.

Try pinging the 'servername'. A quick fix would probably be to switch from the domain name to the IP address in the 'servername' variable.

Also, try googling for: Errno 11001 getaddrinfo.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.