コード例 #1
0
ファイル: entities.py プロジェクト: ChowNow/blingalytics
def init_db_from_scratch():
    """Build the necessary stuff in the db to run."""
    init_db()
    elixir.drop_all()
    elixir.create_all()
    elixir.metadata.bind.execute(FIRST_FUNCTION)
    filler_data()
コード例 #2
0
ファイル: manager.py プロジェクト: julienrott/annuaire
def install():
    """ Install database an default values """

    # Drop tables
    print("Dropping all tables...")
    drop_all()

    # Create tables
    print("Creating all tables...")
    create_all()
    
    
    # Create default data
    buildingA = Localisation(building=u"Batiment A", floor=1)
    buildingB = Localisation(building=u"Batiment B", floor=1, phone=u"5104")
    buildingC = Localisation(building=u"Batiment C", floor=2, phone=u"3388")
    
    Person(firstname=u"Stéphanie", lastname=u"De Monaco", birthdate=date(1980, 4, 4), localisation=buildingA)
    Person(firstname=u"Jean", lastname=u"Delarue", birthdate=date(1960, 10, 6), localisation=buildingA)
    Person(firstname=u"Jean-Pierre", lastname=u"Pernault", birthdate=date(1981, 7, 4), localisation=buildingB)
    Person(firstname=u"Anne", lastname=u"Sinclair", birthdate=date(1975, 8, 7), localisation=buildingC)
    Person(firstname=u"Julien", lastname=u"Lepers", birthdate=date(1975, 8, 7), localisation=buildingC)

    Team(name=u"Manchester")
    Team(name=u"Barça")
    Team(name=u"Racing Club de Strasbourg")
    
    session.commit()
    
    print("Installation success with data test")
コード例 #3
0
def init_db_from_scratch():
    """Build the necessary stuff in the db to run."""
    init_db()
    elixir.drop_all()
    elixir.create_all()
    elixir.metadata.bind.execute(FIRST_FUNCTION)
    filler_data()
コード例 #4
0
ファイル: models.py プロジェクト: rcoacci/PyStockFlow
def initDB(drop=False):

    from elixir import metadata, setup_all, drop_all, create_all
    from genericpath import exists
    from os import makedirs
    from posixpath import expanduser

    DB_NAME = "stockflow.sqlite"
    log = logging.getLogger(__name__)
    log.info("Inicializando o Core")
    dbpath = expanduser("~/.stockflow/")
    if not exists(dbpath):
        try:
            makedirs(dbpath)
        except OSError:
            log.warning("Nao foi possivel criar os diretorios, \
                usando o home do usuário.")
            dbpath = expanduser("~")

    metadata.bind = "".join(("sqlite:///", dbpath, DB_NAME))
    metadata.bind.echo = False

    setup_all()
    if(drop):
        drop_all()


    if not exists("".join((dbpath, DB_NAME))) or drop:
        log.debug("Criando tabelas...")
        create_all()
コード例 #5
0
ファイル: SetupDatabase.py プロジェクト: Frihet/argentum
def setup(options, kws, files, model = None):
    if model is None:
        model = load_model(options, kws, files)
    
    if 'drop' in options:
        print "DROPPING ALL TABLES"
        elixir.drop_all(bind=model.engine)

    if 'schema' in options or 'all' in options:
        print "CREATING TABLES"
        elixir.create_all(bind=model.engine)

    if 'views' in options:
        print "(RE)CREATING VIEWS"
        with model.engine.Session() as session:
            for view_method in elixir.metadata.ddl_listeners['after-create']:
                view = view_method.im_self
                if isinstance(view, Argentum.View):
                    if not 'skip-materialized' in options or not view.is_materialized:
                        view_method(None, elixir.metadata, session.bind)

    if 'data' in options or 'all' in options:
        print "INSERTING ORIGINAL DATA"
        with model.engine.Session() as session:
            model.createInitialData(session, *options, **kws)
コード例 #6
0
    def tearDown(self):
        e.drop_all()
        e.session.rollback()
        e.session.expunge_all()

        pyamf.unregister_class(Movie)
        pyamf.unregister_class(Genre)
        pyamf.unregister_class(Director)
コード例 #7
0
ファイル: helpers.py プロジェクト: tageorgiou/flask-restless
    def tearDown(self):
        """Drops all tables from the temporary database and closes and unlink
        the temporary file in which it lived.

        """
        drop_all()
        session.commit()
        os.close(self.db_fd)
        os.unlink(self.db_file)
コード例 #8
0
ファイル: db.py プロジェクト: nsi-iff/pyOLS
 def reset(self):
     """ Clean out and reset the database.
     > db.connect(...)
     > db.create()
     ... add things ...
     > db.reset()
     The db is now at the state it was when create() was called. """
     # Probably only useful during testing...
     objectstore.clear()
     drop_all()
     setup_all(create_tables=True)
コード例 #9
0
ファイル: db.py プロジェクト: nsi-iff/pyOLS
 def reset(self):
     """ Clean out and reset the database.
     > db.connect(...)
     > db.create()
     ... add things ...
     > db.reset()
     The db is now at the state it was when create() was called. """
     # Probably only useful during testing...
     objectstore.clear()
     drop_all()
     setup_all(create_tables=True)
コード例 #10
0
ファイル: manager.py プロジェクト: t00f/Flask-server-test
def install():
    """ Install database an default values """

    # Drop tables
    print("Dropping all tables...")
    drop_all()

    # Create tables
    print("Creating all tables...")
    create_all()

    # Add fixtures
    print("Adding default values...")
    for i in range (0, 10000):
        Area(id=i, name=u"Area" + str(i), comment="")

    session.commit()

    # Installation finished
    print("Installation success !")
コード例 #11
0
 def tearDown(self):
     """Method used to destroy a database"""
     session.rollback()
     drop_all()
コード例 #12
0
 def tearDown(self):
     session.close()
     drop_all()
コード例 #13
0
 def tearDownClass(self):
     # clear the session and rollback any open transaction
     session.close()
     # drop all tables, so that we don't leak any data from one test to the
     # other
     drop_all()
コード例 #14
0
ファイル: __init__.py プロジェクト: hoozifachi/hubbub
def reset():
    session.close()
    drop_all()
コード例 #15
0
ファイル: test_database.py プロジェクト: rezaghanimi/core
def teardown_function(_):
    session.expunge_all()
    drop_all()
コード例 #16
0
ファイル: test_database.py プロジェクト: nagareproject/core
def teardown_function(_):
    session.expunge_all()
    drop_all()
コード例 #17
0
ファイル: orm_comp.py プロジェクト: stanfeldman/samples
class Person(Entity):
	using_options(inheritance="multi")
	name = Field(Unicode)
	def __repr__(self):
		return '<Person(%s) "%s">' % (self.__class__.__name__, self.name)
	
class Actor(Person):
	using_options(inheritance="multi")
	a = Field(Unicode)
	
class Director(Person):
	using_options(inheritance="multi")
	d = Field(Unicode)

setup_all()
drop_all()
create_all()
start_time = time()
Movie(title=u"Blade Runner", year=1982)
session.commit()
elixir_create_time = (time()-start_time)*1000
start_time = time()
print Movie.query.all()
elixir_select_time = (time()-start_time)*1000
start_time = time()
movie = Movie.query.first()
movie.year = 2222
session.commit()
elixir_edit_time = (time()-start_time)*1000
print Movie.query.all()
start_time = time()