(self)
# Eventually, there will be multi-user support, but for now,
        # just have a single user entry
        results = session.query(User).first()
        if results is None:
           user = User()
           user.name = ""
           user.password_digest = utils.getDigest("")
           session.add(user)
           session.commit()
# Eventually, there will be multi-user support, but for now,
        # just have a single user entry
        results = session.query(User).first()
        if results is None:
           user = User()
           user.name = ""
           user.password_digest = utils.getDigest("")
           session.add(user)
           session.commit()
# Eventually there will be multi - user support but for now # just have a single user entry results = session . query ( User ) . first () if results is None : user = User () user . name = user . password_digest = utils . getDigest ( ) session . add ( user ) session . commit ()
def create(self):
        
        self.engine = create_engine('sqlite:///'+ self.dbfile, echo=False)

        session_factory = sessionmaker(bind=self.engine)
        self.Session = scoped_session(session_factory) 

        # if we don't have a UUID for this DB, add it.
        Base.metadata.create_all(self.engine) 

        session = self.Session()
 
        results = session.query(SchemaInfo).first()
        if results is None:
           schemainfo = SchemaInfo()
           schemainfo.schema_version = SCHEMA_VERSION
           session.add(schemainfo)
           logging.debug("Setting scheme version".format(schemainfo.schema_version))
           session.commit()
        else:
            if results.schema_version != SCHEMA_VERSION:
                raise SchemaVersionException
        
        results = session.query(DatabaseInfo).first()
        if results is None:
           dbinfo = DatabaseInfo()
           dbinfo.uuid = unicode(uuid.uuid4().hex)
           dbinfo.last_updated = datetime.utcnow()
           session.add(dbinfo)
           session.commit()
           logging.debug("Added new uuid".format(dbinfo.uuid))

        """
        # Eventually, there will be multi-user support, but for now,
        # just have a single user entry
        results = session.query(User).first()
        if results is None:
           user = User()
           user.name = ""
           user.password_digest = utils.getDigest("")
           session.add(user)
           session.commit()
        """
def create ( self ) : self . engine = create_engine ( 'sqlite:///' + self . dbfile , echo = False ) session_factory = sessionmaker ( bind = self . engine ) self . Session = scoped_session ( session_factory ) # if we don't have a UUID for this DB, add it. Base . metadata . create_all ( self . engine ) session = self . Session ( ) results = session . query ( SchemaInfo ) . first ( ) if results is None : schemainfo = SchemaInfo ( ) schemainfo . schema_version = SCHEMA_VERSION session . add ( schemainfo ) logging . debug ( "Setting scheme version" . format ( schemainfo . schema_version ) ) session . commit ( ) else : if results . schema_version != SCHEMA_VERSION : raise SchemaVersionException results = session . query ( DatabaseInfo ) . first ( ) if results is None : dbinfo = DatabaseInfo ( ) dbinfo . uuid = unicode ( uuid . uuid4 ( ) . hex ) dbinfo . last_updated = datetime . utcnow ( ) session . add ( dbinfo ) session . commit ( ) logging . debug ( "Added new uuid" . format ( dbinfo . uuid ) )