sqlite and TemporaryFile under Windows
Paul McNett
p at ulmcnett.com
Mon Oct 15 17:25:08 EDT 2007
Matthieu Brucher wrote:
> Are you aware that you can do an in-memory database (IOW no file at
> all)?
>
> cur = sqlite.connect (":memory:")
>
>
> Yes, but in this case, how can I use the DB that I downloaded from the net ?
Ah, sorry, I guess I missed that part.
> If this is the way of using sqlite, it is still cumbersome as a lot of
> other classes that work on files can work on file-like (and isn't it the
> whole point of Python ;) ?
I don't think that sqlite can work on streams, or on file-like objects.
You could just save it as tempfile.mktemp(). I think the utility of this
function in this case outweighs the possibility that your routine will
coincidentally overwrite another file of the same name within the same
fraction of a second. The warning is dire, but when you think about it
in context it doesn't seem that bloody likely that there will be a
problem. ;)
--
pkm ~ http://paulmcnett.com
More information about the Python-list
mailing list