コード例 #1
0
ファイル: prove_speed.py プロジェクト: alampada/py-upsert
def run_upsert():
    cur = conn1.cursor()
    cur.execute('delete from pets')
    upsert = Upsert(cur, 'pets')
    for (selector, setter) in lotsa_records:
        upsert.row(selector, setter)
    cur.close()
コード例 #2
0
def run_upsert():
    cur = conn1.cursor()
    cur.execute('delete from pets')
    upsert = Upsert(cur, 'pets')
    for (selector, setter) in lotsa_records:
        upsert.row(selector, setter)
    cur.close()
コード例 #3
0
 def test_update_1_0(self):
     #print(sys._getframe(0).f_code.co_name)
     self.execute_sql('INSERT INTO pets (name) VALUES (%s)', ('Jerry',))
     upsert = Upsert(self.cursor, 'pets')
     upsert.row({'name': 'Jerry'})
     self.execute_sql("select name from pets")
     self.assertEqual('Jerry', self.cursor.fetchone()[0])
コード例 #4
0
 def test_insert_2_0(self):
     #print(sys._getframe(0).f_code.co_name)
     upsert = Upsert(self.cursor, 'pets')
     upsert.row({'name': 'Jerry', 'color': 'brown2'})
     self.execute_sql("select name, color from pets")
     res = self.cursor.fetchone()
     self.assertEqual('Jerry', res[0])
     self.assertEqual('brown2', res[1])
コード例 #5
0
 def test_update_2_0_miss(self):
     #print(sys._getframe(0).f_code.co_name)
     self.execute_sql('INSERT INTO pets (name, color) VALUES (%s, %s)', ('Jerry', 'red'))
     upsert = Upsert(self.cursor, 'pets')
     upsert.row({'name': 'Jerry', 'color': 'brown7'})
     self.execute_sql("select name, color from pets")
     res = self.cursor.fetchone()
     self.assertEqual('Jerry', res[0])
     self.assertEqual('red', res[1])
コード例 #6
0
 def test_insert_1_2(self):
     #print(sys._getframe(0).f_code.co_name)
     upsert = Upsert(self.cursor, 'pets')
     upsert.row({'name': 'Jerry'}, {'color': 'brown3', 'weight': 256.78})
     self.execute_sql("select name, color, weight from pets")
     res = self.cursor.fetchone()
     self.assertEqual('Jerry', res[0])
     self.assertEqual('brown3', res[1])
     self.assertEqual(256.78, res[2])
コード例 #7
0
 def test_update_1_2(self):
     #print(sys._getframe(0).f_code.co_name)
     self.execute_sql('INSERT INTO pets (name, color, weight) VALUES (%s, %s, %s)', ('Jerry', 'red', 123.456))
     upsert = Upsert(self.cursor, 'pets')
     upsert.row({'name': 'Jerry'}, {'color': 'brown6', 'weight': 256.78})
     self.execute_sql("select name, color, weight from pets")
     res = self.cursor.fetchone()
     self.assertEqual('Jerry', res[0])
     self.assertEqual('brown6', res[1])
     self.assertEqual(256.78, res[2])
コード例 #8
0
 def test_update_2_2_miss(self):
     #print(sys._getframe(0).f_code.co_name)
     self.execute_sql('INSERT INTO pets (name, color, weight, license) VALUES (%s, %s, %s, %s)', ('Jerry', 'red', 123.456, 555))
     upsert = Upsert(self.cursor, 'pets')
     upsert.row({'name': 'Jerry', 'color': 'brown9'}, {'weight': 256.78, 'license': 888})
     self.execute_sql("select name, color, weight, license from pets")
     res = self.cursor.fetchone()
     self.assertEqual('Jerry', res[0])
     self.assertEqual('red', res[1])
     self.assertEqual(123.456, res[2]) 
     self.assertEqual(555, res[3])
コード例 #9
0
 def test_insert_1_0(self):
     #print(sys._getframe(0).f_code.co_name)
     upsert = Upsert(self.cursor, 'pets')
     upsert.row({'name': 'Jerry'})
     self.execute_sql("select name from pets")
     self.assertEqual('Jerry', self.cursor.fetchone()[0])