Issue #21 resolved

_looks_like_ipaddress() fails for certain DNS hostnames

Anonymous created an issue

When the HOST setting for a database is set to a host name of the form (x,y,z being arbitrary strings), and I run "python sql SomeDjangoApp", _looks_like_ipaddress fails because it calls int() on the string x, which raises an exception (below).

Traceback (most recent call last): File "", line 14, in <module> execute_manager(settings) File "c:\Python27\lib\site-packages\django\core\", line 459, in execute_manager utility.execute() File "c:\Python27\lib\site-packages\django\core\", line 382, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "c:\Python27\lib\site-packages\django\core\management\", line 196, in run_from_argv self.execute(args, options.dict) File "c:\Python27\lib\site-packages\django\core\management\", line 232, in execute output = self.handle(*args, options) File "c:\Python27\lib\site-packages\django\core\management\", line 304, in handle app_output = self.handle_app(app, *options) File "c:\Python27\lib\site-packages\django\core\management\commands\", l ine 19, in handle_app return u'\n'.join(sql_create(app,, connections[options.get('datab ase')])).encode('utf-8') File "c:\Python27\lib\site-packages\django\core\management\", line 26, i n sql_create tables = connection.introspection.table_names() File "c:\Python27\lib\site-packages\django\db\", line 895, in table_names cursor = self.connection.cursor() File "c:\Python27\lib\site-packages\django\db\", line 306, in cursor cursor = self.make_debug_cursor(self._cursor()) File "c:\Python27\lib\site-packages\sqlserver_ado\", line 193, in _curs or self.connect() File "c:\Python27\lib\site-packages\sqlserver_ado\", line 166, in con nect make_connection_string(self.settings_dict), File "c:\Python27\lib\site-packages\sqlserver_ado\", line 71, in make_c onnection_string if not _looks_like_ipaddress(db_host): File "c:\Python27\lib\site-packages\sqlserver_ado\", line 32, in _looks _like_ipaddress if not 0 <= int(item) <= 255: ValueError: invalid literal for int() with base 10: 'x'

Comments (2)

  1. Michael Manfre repo owner

    The HOST is only checked for an IP Address when you specify a port. I'm not sure if the drivers still require an IP address to be used with a port, or if you can specify a FQDN. Either way, the IP address validation should not crash. Whether or not a FQDN may be used with a PORT in the connection string (for a particular driver) is out of scope for this issue.

  2. Log in to comment