Hello everyone, I'm having a problem connecting to SQLite database files with SQLAlchemy. :memory: databases work just fine, but whenever I'm trying to access a file, the following happens:
Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win 32 Type "help", "copyright", "credits" or "license" for more information. >>> from sqlalchemy import create_engine >>> import os.path >>> os.path.exists('test.db') False >>> engine = create_engine('sqlite:///test.db') >>> engine.connect <bound method Engine.connect of Engine(sqlite:///test.db)> >>> engine.connect() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\base.py", line 2310, in connect return self._connection_cls(self, **kwargs) File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\base.py", line 872, in __init__ self.__connection = connection or engine.raw_connection() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\base.py", line 2396, in raw_connection return self.pool.unique_connection() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 169, in unique_connection return _ConnectionFairy(self).checkout() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 370, in __init__ rec = self._connection_record = pool._do_get() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 757, in _do_get return self._create_connection() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 174, in _create_connection return _ConnectionRecord(self) File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 255, in __init__ self.connection = self.__connect() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 315, in __connect connection = self.__pool._creator() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\strategies.py", line 80, in connect return dialect.connect(*cargs, **cparams) File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\default.py", line 275, in connect return self.dbapi.connect(*cargs, **cparams) sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None The same happens after having created the database using the sqlite3 module and then trying to connect to it via SQLAlchemy. >>> import sqlite3 >>> conn = sqlite3.connect('test.db') >>> conn.execute('create table bla(id int primary key);') <sqlite3.Cursor object at 0x0000000002FA62D0> >>> conn.close() >>> os.path.exists('test.db') True >>> engine = create_engine('sqlite:///test.db') >>> engine.connect() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\base.py", line 2310, in connect return self._connection_cls(self, **kwargs) File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\base.py", line 872, in __init__ self.__connection = connection or engine.raw_connection() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\base.py", line 2396, in raw_connection return self.pool.unique_connection() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 169, in unique_connection return _ConnectionFairy(self).checkout() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 370, in __init__ rec = self._connection_record = pool._do_get() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 757, in _do_get return self._create_connection() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 174, in _create_connection return _ConnectionRecord(self) File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 255, in __init__ self.connection = self.__connect() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\pool .py", line 315, in __connect connection = self.__pool._creator() File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\strategies.py", line 80, in connect return dialect.connect(*cargs, **cparams) File "C:\Python27\lib\site-packages\sqlalchemy-0.7.2-py2.7.egg\sqlalchemy\engi ne\default.py", line 275, in connect return self.dbapi.connect(*cargs, **cparams) sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None So have you got any idea on what might be problem here? -- João Silva -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.