How to use SQLObject - 10 common examples

To help you get started, we’ve selected a few SQLObject examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sqlobject / sqlobject / tests / test_converters.py View on Github external
def test_instance(self):
        instance = TestClass()
        self.assertEqual(sqlrepr(instance), repr(instance))
github sqlobject / sqlobject / tests / test_converters.py View on Github external
def test_op(self):
        instance = SQLOp('and', 'this', 'that')
        self.assertEqual(sqlrepr(instance), repr(instance))
github sqlobject / sqlobject / tests / test_converters.py View on Github external
def test_newstyle(self):
        instance = NewTestClass()
        self.assertEqual(sqlrepr(instance), repr(instance))
github sqlobject / sqlobject / tests / test_converters.py View on Github external
def test_bool(self):
        self.assertEqual(sqlrepr(TRUE, 'postgres'), "'t'")
        self.assertEqual(sqlrepr(FALSE, 'postgres'), "'f'")
        self.assertEqual(sqlrepr(TRUE, 'mysql'), "1")
        self.assertEqual(sqlrepr(FALSE, 'mysql'), "0")
github sqlobject / sqlobject / tests / test_converters.py View on Github external
def test_string_b(self):
        self.assertEqual(sqlrepr('A String\bAnother', 'postgres'), "'A String\\bAnother'")
github sqlobject / sqlobject / tests / test_converters.py View on Github external
def test_delete(self):
        instance = Delete('test', None)
        self.assertEqual(sqlrepr(instance), repr(instance))
github sqlobject / sqlobject / tests / test_converters.py View on Github external
def test_op(self):
        instance = SQLOp('and', 'this', 'that')
        self.assertEqual(sqlrepr(instance), repr(instance))
github sqlobject / sqlobject / tests / test_converters.py View on Github external
def test_select(self):
        instance = Select('test')
        self.assertEqual(sqlrepr(instance), repr(instance))
github iven / Yaner / yaner / Category.py View on Github external
This module contains the L{Category} presentable of L{yaner}.
"""

import sqlobject

from yaner.Presentable import Presentable

class Category(Presentable, sqlobject.SQLObject):
    """
    Category presentable of the L{Pool}s.
    """

    name = sqlobject.UnicodeCol()
    directory = sqlobject.UnicodeCol()

    pool = sqlobject.ForeignKey('Pool')
    tasks = sqlobject.MultipleJoin('Task')

    def _init(self, *args, **kwargs):
        Presentable.__init__(self)
        sqlobject.SQLObject._init(self, *args, **kwargs)

        self.parent = kwargs['queuing']
        self.icon = "gtk-directory"

    @property
    def description(self):
        """Get the description of the presentable."""
        return "This is a category."
github stoq / stoq / stoq / domain / payment.py View on Github external
class AbstractPaymentGroup(InheritableModelAdapter):

    (STATUS_PREVIEW, 
     STATUS_OPEN, 
     STATUS_CLOSED, 
     STATUS_CANCELLED) = range(4)

    __implements__ = IPaymentGroup, IContainer

    status = IntCol(default=STATUS_OPEN)
    open_date = DateTimeCol(default=datetime.now())
    close_date = DateTimeCol(default=None)
    notes = StringCol(default='')
    thirdparty = ForeignKey('Person')


    def set_thirdparty(self, person):
        if not isinstance(person, Person):
            raise TypeError("A Person object is required for set_thirdparty, "
                            "got %s instead." % type(person))
        self.thirdparty = person

    def get_thirdparty(self):
        return self.thirdparty

    def get_balance(self):
        values = [s.value for s in self.get_items()]
        return reduce(operator.add, values, 0.0)

    def add_debit(self, value, reason, category, date=None):