0

I have this 2 SQLite scripts: both tested by direct input into SQLite.

 def getOutgoingLinks(self, hostname):
    t = (hostname,)
    result = self.__cursor.execute("SELECT url.id, hostname.name, url.path, linking_to.keyword, siteId.id " +
                                    "FROM url, hostname, linking_to, " +
                                    "(SELECT url.id FROM url, hostname " +
                                    "WHERE hostname.name = (?) " +
                                    "AND hostname.id = url.hostname_id " +
                                    ") AS siteId " +
                                    "WHERE linking_to.from_id = siteId.id " +
                                    "AND linking_to.to_id = url.id " +
                                    "AND url.hostname_id = hostname.id", t)        
    result = result.fetchall()
    return result

def getIncommingLinks(self, hostname):
    t = (hostname,)
    result = self.__cursor.execute("SELECT url.id, hostname.name, url.path, linking_to.keyword, siteId.id " +
                                    "FROM url, hostname, linking_to, " +
                                    "(SELECT url.id FROM url, hostname " +
                                    "WHERE hostname.name = (?) " +
                                    "AND hostname.id = url.hostname_id " +
                                    ") AS siteId " +
                                    "WHERE linking_to.to_id = siteId.id " +
                                    "AND linking_to.from_id = url.id " +
                                    "AND url.hostname_id = hostname.id", t)
    result = result.fetchall()
    return result

The getIncommingLinks() methond works very well, but getOutgoingLinks() causes an infinite Loop when python trys to execute the SQL statement. Any ideas what went wrong?

2 Answers2

0

Rewrite your Select statements without select ...( Select ...) - thats very bad style. The result may solve your problem.

Tofix
  • 1
0

If by infinite loop you mean that the function doesnt ever get to return a value, I had the same problem.

Found the solution in Why python+sqlite3 is extremely slow?. With large tables it becomes a performance issue with the version shipped with python 2.7. I solved it by upgrading sqlite3 as specified here: https://stackoverflow.com/a/3341117/3894804

Community
  • 1
  • 1
ocspro
  • 101
  • 1