github.com/dolthub/go-mysql-server@v0.18.0/_integration/python-mysql/test.py (about) 1 # Copyright 2020-2021 Dolthub, Inc. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # 15 # Licensed under the Apache License, Version 2.0 (the "License"); 16 # you may not use this file except in compliance with the License. 17 # You may obtain a copy of the License at 18 # 19 # http://www.apache.org/licenses/LICENSE-2.0 20 # 21 # Unless required by applicable law or agreed to in writing, software 22 # distributed under the License is distributed on an "AS IS" BASIS, 23 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 24 # See the License for the specific language governing permissions and 25 # limitations under the License. 26 27 import unittest 28 import mysql.connector 29 30 class TestMySQL(unittest.TestCase): 31 32 def test_connect(self): 33 connection = mysql.connector.connect(host='127.0.0.1', 34 user='root', 35 passwd='', 36 database="mydb") 37 38 try: 39 cursor = connection.cursor() 40 sql = "SELECT name, email FROM mytable ORDER BY name, email" 41 cursor.execute(sql) 42 rows = cursor.fetchall() 43 44 expected = [ 45 ("Evil Bob", "evilbob@gmail.com"), 46 ("Jane Doe", "jane@doe.com"), 47 ("John Doe", "john@doe.com"), 48 ("John Doe", "johnalt@doe.com") 49 ] 50 51 self.assertEqual(expected, rows) 52 finally: 53 connection.close() 54 55 56 if __name__ == '__main__': 57 unittest.main()