def test_delete(self):
     sql = sqlpuzzle.delete().from_('user').where(id=42)
     self.assertEqual(str(sql), 'DELETE FROM "user" WHERE "id" = 42')
def test_delete():
    sql = sqlpuzzle.delete().from_('user').where(id=42)
    assert str(sql) == 'DELETE FROM "user" WHERE "id" = 42'
Example #3
0
# - - ConfirmDeleteAllException
# - InvalidArgumentException
# - - InvalidQueryException
#

try:
    sqlpuzzle.select(True)
except sqlpuzzle.exceptions.InvalidArgumentException, e:
    print('catched:', e)

try:
    print(sqlpuzzle.select_from('t').on('t2'))
except sqlpuzzle.exceptions.InvalidQueryException, e:
    print('catched:', e)

try:
    print(sqlpuzzle.update('table').set(name='Alan'))
except sqlpuzzle.exceptions.ConfirmUpdateAllException, e:
    print('catched:', e)

try:
    print(sqlpuzzle.delete().from_('table'))
except sqlpuzzle.exceptions.ConfirmDeleteAllException, e:
    print('catched:', e)

# All exceptions are inherited from SqlPuzzleException.
try:
    sqlpuzzle.select(1)
except sqlpuzzle.exceptions.SqlPuzzleException, e:
    print('catched:', e)
Example #4
0
 def test_delete(self):
     sql = sqlpuzzle.delete().from_('user').where(id=42)
     self.assertEqual(str(sql), 'DELETE FROM "user" WHERE "id" = 42')
Example #5
0
# - InvalidArgumentException
# - - InvalidQueryException
#

try:
    sqlpuzzle.select(True)
except sqlpuzzle.exceptions.InvalidArgumentException, e:
    print('catched:', e)

try:
    print(sqlpuzzle.select_from('t').on('t2'))
except sqlpuzzle.exceptions.InvalidQueryException, e:
    print('catched:', e)

try:
    print(sqlpuzzle.update('table').set(name='Alan'))
except sqlpuzzle.exceptions.ConfirmUpdateAllException, e:
    print('catched:', e)

try:
    print(sqlpuzzle.delete().from_('table'))
except sqlpuzzle.exceptions.ConfirmDeleteAllException, e:
    print('catched:', e)


# All exceptions are inherited from SqlPuzzleException.
try:
    sqlpuzzle.select(1)
except sqlpuzzle.exceptions.SqlPuzzleException, e:
    print('catched:', e)
Example #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sqlpuzzle
import sqlpuzzle.exceptions

sql = sqlpuzzle.delete().from_('table')

try:
    print(sql)
except sqlpuzzle.exceptions.ConfirmDeleteAllException:
    pass  # delete all records is not enabled by default

sql.allow_delete_all()
print(sql)
# output: DELETE FROM `table`

try:
    sql.forbid_delete_all()
    print(sql)
except sqlpuzzle.exceptions.ConfirmDeleteAllException:
    pass  # protected of delete all records can be turned on again

sql.where(id=42)
print(sql)
# output: DELETE FROM `table` WHERE `id` = 42

print(sqlpuzzle.delete_from('table').where(id=42))
# same output as previous command
Example #7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sqlpuzzle
import sqlpuzzle.exceptions


sql = sqlpuzzle.delete().from_('table')

try:
    print(sql)
except sqlpuzzle.exceptions.ConfirmDeleteAllException:
    pass  # delete all records is not enabled by default

sql.allow_delete_all()
print(sql)
# output: DELETE FROM `table`

try:
    sql.forbid_delete_all()
    print(sql)
except sqlpuzzle.exceptions.ConfirmDeleteAllException:
    pass  # protected of delete all records can be turned on again

sql.where(id=42)
print(sql)
# output: DELETE FROM `table` WHERE `id` = 42

print(sqlpuzzle.delete_from('table').where(id=42))
# same output as previous command
def test_delete():
    sql = sqlpuzzle.delete().from_('user').where(id=42)
    assert str(sql) == 'DELETE FROM "user" WHERE "id" = 42'