cannot connect to in-memory SQLite DB using SQLAlchemy with Python 2.7.3 on Windows
python, sqlalchemy, sqlite
Solution
The filename should be `:memory:`, not `memory:`. (See the docs for in-memory databases). The relevant SQLAlchemy docs mention that's the default path, so you should use:
engine=create_engine('sqlite://',echo=True)
The error you're getting is presumably because `memory:` isn't a valid filename on Windows.
Problem
I am trying to use the in-memory SQLite database using SQLAlchemy with Python 2.7.3 on Windows. I can connect to the engine, but when I try to execute the second statement I am getting the following error: ``` >>> engine=create_engine('sqlite:///memory:',echo=True) >>> engine.execute("select 1").scalar() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 2445, in execute connection = self.contextual_connect(close_with_result=True) File "C:\Python27\lib\site-packages\sqlalchemy\engine\base.py", line 2489, in contextual_connect self.pool.connect(), File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 236, in connect return _ConnectionFairy(self).checkout() File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 401, in __init__ rec = self._connection_record = pool._do_get() File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 822, in _do_get return self._create_connection() File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 189, in _create_connection return _ConnectionRecord(self) File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 282, in __init__ self.connection = self.__connect() File "C:\Python27\lib\site-packages\sqlalchemy\pool.py", line 344, in __connect connection = self.__pool._creator() File "C:\Python27\lib\site-packages\sqlalchemy\engine\strategies.py", line 80, in connect return dialect.connect(*cargs, **cparams) File "C:\Python27\lib\site-packages\sqlalchemy\engine\default.py", line 281, in connect return self.dbapi.connect(*cargs, **cparams) sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None ```