示例#1
0
 def test_insert_functions(self):
     s = SQLGenerator()
     params = {
         'nom': 'dupont',
         'prenom': 'jean',
         'age': SQLExpression('YEARS(%(date)s)', date='2013/01/01')
     }
     sqlstr = s.insert('test', params)
     self.assertEqual(
         sqlstr, 'INSERT INTO test ( age, nom, prenom ) VALUES '
         '( YEARS(%(date)s), %(nom)s, %(prenom)s )')
     self.assertEqual(params, {
         'nom': 'dupont',
         'prenom': 'jean',
         'date': '2013/01/01'
     })
示例#2
0
 def test_insert_values(self):
     s = SQLGenerator()
     params = {'nom': 'dupont'}
     sqlstr = s.insert('test', params)
     self.assertEqual(sqlstr, 'INSERT INTO test ( nom ) VALUES ( %(nom)s )')
     self.assertEqual(params, {'nom': 'dupont'})