how are the permissions on this file path:

/test.db 

?

do you really want your database file in the root directory like that?


On Jul 21, 2014, at 2:58 PM, Imk Hacked <ihacked1...@gmail.com> wrote:

> Hello guys,
> I am learning Flask, I new started sqlalchemy with flask, so very easy is 
> both.
> I am working with wtforms flask extension and sqlalchemy for flask extension.
> 
> My Application and database initalize,
> 
> app = Flask(__name__)
> # app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////:memory:'
> app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////test.db'
> db = SQLAlchemy(app)
> 
> And my sqlalchemy User table,
> 
> class User(db.Model):
>     id = db.Column(db.Integer, primary_key=True)
>     mail = db.Column(db.String(120), unique=True)
>     psw = db.Column(db.String(26), unique=True)
>     
>     def __init__(self,mail,psw):
>         self.mail = mail
>         self.psw = psw
>         
>     def __repr__(self):
>         return '<User %r - %r>'%(self.mail, self.psw)
> 
> After I am calling db.create_all() func.
> For example my simple register page,
> 
> @app.route('/reg')
> def register():
>     formUser = userReg(request.form)
>     if request.method == "POST" and formUser.validate():
>             session['userEnabled'] = 1 #php style :)/>/>
>             session['mail'] = formUser.mail.data
>             session['psw'] = formUser.psw.data
>             uyeObj = Kullanici("%s"%formUser.mail.data,"%s"%formUser.psw.data)
>             db.session.add(uyeObj)
>             db.session.commit()
>             return redirect('/profile')
>     return render_template('register.html', form=formUser)
> 
> 
> I must this code checking, and as test, I am calling this function 
> User.query.all()
> Here is error result
> 
> Traceback (most recent call last):
>   File "C:\Users\user\Desktop\Flask\test\test.py", line 130, in <module>
>     xx = User.query.all()
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\orm\query.py",
>  line 2293, in all
>     return list(self)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\orm\query.py",
>  line 2405, in __iter__
>     return self._execute_and_instances(context)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\orm\query.py",
>  line 2418, in _execute_and_instances
>     close_with_result=True)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\orm\query.py",
>  line 2409, in _connection_from_session
>     **kw)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\orm\session.py",
>  line 846, in connection
>     close_with_result=close_with_result)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\orm\session.py",
>  line 850, in _connection_for_bind
>     return self.transaction._connection_for_bind(engine)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\orm\session.py",
>  line 315, in _connection_for_bind
>     conn = bind.contextual_connect()
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\engine\base.py",
>  line 1737, in contextual_connect
>     self.pool.connect(),
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\pool.py",
>  line 332, in connect
>     return _ConnectionFairy._checkout(self)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\pool.py",
>  line 630, in _checkout
>     fairy = _ConnectionRecord.checkout(pool)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\pool.py",
>  line 433, in checkout
>     rec = pool._do_get()
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\pool.py",
>  line 1042, in _do_get
>     return self._create_connection()
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\pool.py",
>  line 278, in _create_connection
>     return _ConnectionRecord(self)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\pool.py",
>  line 404, in __init__
>     self.connection = self.__connect()
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\pool.py",
>  line 530, in __connect
>     connection = self.__pool._creator()
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\engine\strategies.py",
>  line 95, in connect
>     connection_invalidated=invalidated
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\util\compat.py",
>  line 189, in raise_from_cause
>     reraise(type(exception), exception, tb=exc_tb)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\engine\strategies.py",
>  line 89, in connect
>     return dialect.connect(*cargs, **cparams)
>   File 
> "C:\Python27\lib\site-packages\sqlalchemy-0.9.6-py2.7-win32.egg\sqlalchemy\engine\default.py",
>  line 376, in connect
>     return self.dbapi.connect(*cargs, **cparams)
> OperationalError: (OperationalError) unable to open database file None None
> 
> How we do solve? I am trying two days. Today second day.
> 
> Thank you for interest.
> Good works my friends. 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to