Ejemplo n.º 1
0
# Using obj._mogrify() to display the SQL request
the_authors_of_posts_commented_by_gaston._mogrify()
input("continue ")

persons.delete(delete_all=True)
sys.exit()

# OLD CODE

import os.path
from half_orm.model import Model

dirname = os.path.dirname(__file__)
halftest = Model('{}/halftest.ini'.format(dirname))

person = halftest.relation("actor.person")
print(person)
person.delete(delete_all=True)
post = halftest.relation("blog.post")
print(post)
post.delete(delete_all=True)
comment = halftest.relation("blog.comment")
print(comment)
comment.delete(delete_all=True)

person = halftest.relation("actor.person")
print(type(person.last_name))
# just in case
#person.delete(delete_all=True)

@person.Transaction
Ejemplo n.º 2
0
#!/usr/bin/env python3
#-*- coding: utf-8 -*-

import time
from half_orm.model import Model

dpt_info = Model(config_file='/etc/half_orm/dpt_info')
oidt = dpt_info.relation(
    'collorg.core.oid_table',
    cog_oid=('e%', 'like'), cog_fqtn='seminaire.session')
for elt in oidt.select('cog_oid'):
    print(elt)
print(len(oidt))
oidt.update(cog_fqtn='perdu')
dpt_info.connection.commit()
print(len(oidt))
oidt2 = oidt(cog_fqtn='perdu')
for elt in oidt2.select():
    print(elt)
input('Allez faire un tour sur psql...')
oidt2.update(cog_fqtn='seminaire.session')
dpt_info.connection.commit()
# One model shared by all the tables...
print(id(dpt_info), id(oidt.model), id(oidt2.model))
print(len(oidt2))
Ejemplo n.º 3
0
    PgDatabase()
    relation('dpt_info.seminaire.session')
    sys.exit()
    """
    print(OidTable())
#    print(BaseTable())
#    print(ViewSession())
#    print(relation('dpt_info.seminaire.session'))
#    dpt_info.desc()

    """profiling"""
    for i in range(1000):
        relation('dpt_info."collorg.core".base_table')

    """request with no constraint."""
    bt = dpt_info.relation('"collorg.core".data_type')
    count = 0
    for elt in bt.select():
        count += 1
    print(count)
    bt = dpt_info.relation('"collorg.core".base_table')
    print(type(bt.cog_signature))
    print(bt)
    """Put a constraint on a Field"""
    assert bt.cog_fqtn.is_set() is False
    bt.cog_fqtn = 'collorg.access.access'
    assert bt.cog_fqtn.is_set() is True
    assert bt.cog_oid.is_set() is False
    bt.cog_oid = 'd%', 'like'
    assert bt.cog_oid.is_set() is True
    assert bt.cog_oid.value == 'd%'