<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import psycopg2
from mosql.result2 import Model

class PostgreSQL(Model):
    getconn = classmethod(lambda cls: psycopg2.connect(database='mosky'))
    putconn = classmethod(lambda cls, conn: None)

class Person(PostgreSQL):
    clauses = dict(table='person')
    arrange_by = ('person_id', )

class Detail(PostgreSQL):
    clauses = dict(table='detail')
    arrange_by = ('person_id', 'key')
    squashed = arrange_by
    ident_by = ('detail_id', )

if __name__ == '__main__':

    from pprint import pprint

    d = next(Detail.arrange(where={'person_id': 'mosky'}))
    Detail.dump_sql = True
    Detail.dry_run = True

    print '# original'
    pprint(dict(d))
    print

    print '# setitem'
    d['val', 0] = '<EMAIL>'
    pprint(dict(d))
    print

    print '# append'
    d.append({'val': '<EMAIL>'})
    pprint(dict(d))
    print

    print '# pop it'
    d.pop(0)
    pprint(dict(d))
    print

    print '# save it'
    print d.save()
<commit_msg>test modifying the identity column<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

import psycopg2
from mosql.result2 import Model

class PostgreSQL(Model):
    getconn = classmethod(lambda cls: psycopg2.connect(database='mosky'))
    putconn = classmethod(lambda cls, conn: None)

class Person(PostgreSQL):
    clauses = dict(table='person')
    arrange_by = ('person_id', )

class Detail(PostgreSQL):
    clauses = dict(table='detail')
    arrange_by = ('person_id', 'key')
    squashed = arrange_by
    ident_by = ('detail_id', )

if __name__ == '__main__':

    from pprint import pprint

    d = next(Detail.arrange(where={'person_id': 'mosky'}))
    Detail.dump_sql = True
    Detail.dry_run = True

    print '# original'
    pprint(dict(d))
    print

    print '# setitem'
    d['val', 0] = '<EMAIL>'
    d['detail_id', 0] = 123
    pprint(dict(d))
    print

    print '# append'
    d.append({'val': '<EMAIL>'})
    pprint(dict(d))
    print

    print '# pop it'
    d.pop(0)
    pprint(dict(d))
    print

    print '# save it'
    print d.save()

{'fraction_non_alphanumeric': 0.15274463007159905, 'fraction_numerical': 0.0076372315035799524, 'mean_word_length': 3.1341222879684416, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2844119', 'n_tokens_mistral': 764, 'n_tokens_neox': 752, 'n_words': 167}