Search Results

Search found 3 results on 1 pages for 'gummmibear'.

Page 1/1 | 1 

  • getting last insert id .sqlalchemy orm

    - by gummmibear
    Hi i use sqlalchemy, i need some help. import hashlib import sqlalchemy as sa from sqlalchemy import orm from allsun.model import meta t_user = sa.Table("users",meta.metadata,autoload=True) class Duplicat(Exception): pass class LoginExistsException(Exception): pass class EmailExistsException(Exception): pass class User(object): """ def __setattr__(self, key, value): if key=='password' : value=unicode(hashlib.sha512(value).hexdigset()) object.__setattr__(self,key,value) """ def loginExists(self): try: meta.Session.query(User).filter(User.login==self.login).one() except orm.exc.NoResultFound: pass else: raise LoginExistsException() def emailExists(self): try: meta.Session.query(User).filter(User.email==self.email).one() except orm.exc.NoResultFound: pass else: raise EmailExistsException() def save(self): meta.Session.begin() meta.Session.save(self) try: meta.Session.commit() except sa.exc.IntegrityError: raise Duplicat() How can i get inserted id when i call? user = User() user.login = request.params['login'] user.password = hashlib.sha512(request.params['password']).hexdigest() user.email = request.params['email'] user.save()

    Read the article

  • How to set up global connect to datebase in pylons(python), sqlalchemy.

    - by gummmibear
    Hi! I just start lern python, pylons. i have problem with setting up datebase connection. i won't to set connection, where i can see this connection in all my controllers. Now i use: some thing like this in my controller: 45 ' db = create_engine('mysql://root:password@localhost/python') 46 ' metadata = MetaData(db) 47 48 ' email_list = Table('email',metadata,autoload=True) in development.ini i have: 44 sqlalchemy.url = mysql://root@password@localhost/python 45 sqlalchemy.pool_recycle = 3600 and now, pleas help me to set __init__.py

    Read the article

1