plasticityai / magnitude

A fast, efficient universal vector embedding utility package.
MIT License
1.63k stars 120 forks source link

Can't open db file when creating Magnitude Object #2

Closed yassin-taskin closed 6 years ago

yassin-taskin commented 6 years ago

I tried following the instructions, downloaded a db file and tried out the code

vectors = Magnitude(MAG_PATH)

The file is definitly there but i got an error sqlite3.OperationalError: unable to open database file

When looking at the code this seems to get executed starting at line 346

    if self.fd:
         conn = sqlite3.connect('/dev/fd/%d' % self.fd,
          check_same_thread=False)
    else:
        conn = sqlite3.connect(self.path, check_same_thread=False)
        self._create_empty_db(conn.cursor())

right at the start of the _db() method.

self.fd seems to get set whenever path is not none in the init method it is the return code of os.open(path)

So the path that is tried to open is "/dev/fd/3/" instead of the actual database path

Seems to work when i change the line

conn = sqlite3.connect('/dev/fd/%d' % self.fd,
          check_same_thread=False)

to

conn = sqlite3.connect(self.path,
          check_same_thread=False)
AjayP13 commented 6 years ago

What operating system are you using? macOS and Linux support '/dev/fd/' paths but Windows does not. I wasn't originally targeting support for Windows, but if this is an issue for you I'm happy to fix it to make it compatible.

yassin-taskin commented 6 years ago

Yes i'm using windows. Thank you for your work.

yassin-taskin commented 6 years ago

This got fixed in the update. Thanks Ajay.