Пример #1
0
class PtMySqlTest(unittest.TestCase):
    mysql = None
    def init_mysql(self):
        self.mysql = PtMySql('127.0.0.1','test','root','root')
    def setUp(self):
        self.init_mysql()
    def test_init(self):
        mysql = PtMySql('127.0.0.1','test','root','root')
        self.assertTrue(mysql.conn is not None)
        mysql = PtMySql('127.0.0.1','test',user='******',passwd = 'root')
        self.assertTrue(mysql.conn is not None)
        mysql = PtMySql('127.0.0.1','test',user='******',passwd = 'root',port="3306")
        self.assertTrue(mysql.conn is not None)
    def test_get_now(self):
        now = self.mysql.getNow()
        print now
    def test_runSql(self):
        print self.mysql.runSql("create table test()")
        print self.mysql.query("drop table test;")
Пример #2
0
 def init_mysql(self):
     self.mysql = PtMySql('127.0.0.1','test','root','root')