Example #1
0
the_authors_of_posts_commented_by_gaston = the_posts_commented_by_gaston._fkeys.author()

# 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)
Example #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))
Example #3
0
#!/usr/bin/env python3
#-*- coding: utf-8 -*-

from datetime import datetime
from half_orm.model import Model
from half_orm.relation import RelationFactory, Relation, relation

dpt_info = Model(config_file='/etc/half_orm/dpt_info')

class OidTable(metaclass=RelationFactory):
    fqrn = 'dpt_info."collorg.core".oid_table'

class BaseTable(metaclass=RelationFactory):
    fqrn = '"dpt_info"."collorg.core".base_table'

class ViewSession(metaclass=RelationFactory):
    fqrn = 'dpt_info."seminaire.view"."session"'

if __name__ == '__main__':
    """
    OidTable()
    BaseTable()
    ViewSession()
    PgDatabase()
    relation('dpt_info.seminaire.session')
    sys.exit()
    """
    print(OidTable())
#    print(BaseTable())
#    print(ViewSession())
#    print(relation('dpt_info.seminaire.session'))