piskvorky / sqlitedict

Persistent dict, backed by sqlite3 and pickle, multithread-safe.
Apache License 2.0
1.17k stars 131 forks source link

support sqlitedict in memory #11

Closed ownport closed 10 years ago

ownport commented 10 years ago

To use just define filename as ':memory:'.

d=sqlitedict.SqliteDict(":memory:")
piskvorky commented 10 years ago

@ownport And what is the problem if you do exactly the same with the current version?

ownport commented 10 years ago
Traceback (most recent call last):
  File "/media/data1/dev/virtenvs/github-sqlitedict/src/tests/test_named_db.py", line 22, in tearDown
    self.d.terminate()
  File "/media/data1/dev/virtenvs/github-sqlitedict/src/sqlitedict.py", line 223, in terminate
    os.remove(self.filename)
OSError: [Errno 2] No such file or directory: ':memory:'

Of course we can add handling of this exception but in log we will see

sqlitedict: INFO: deleting :memory:

So it's more syntax sugar that real support of sqlitedict in memory

piskvorky commented 10 years ago

Aha, good catch. The try catch in terminate() only catches IOError, but this is OSError.

I agree we don't need the log line in this case. And thanks for the unittest too :)

Merging.