mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-30 10:45:18 -06:00
Added test for pymysql connection library. Renamed and modified the mysql.connector test based on discoveries writing this test.
This commit is contained in:
@@ -12,7 +12,6 @@ QUERY_RESPONSE = [
|
||||
]
|
||||
|
||||
def main():
|
||||
print(sys.argv)
|
||||
user = sys.argv[1]
|
||||
port = sys.argv[2]
|
||||
db = sys.argv[3]
|
||||
@@ -22,7 +21,6 @@ def main():
|
||||
port=port,
|
||||
database=db)
|
||||
|
||||
|
||||
for query_response in QUERY_RESPONSE:
|
||||
query = list(query_response.keys())[0]
|
||||
exp_results = query_response[query]
|
||||
@@ -33,6 +31,8 @@ def main():
|
||||
print(exp_results)
|
||||
print(results)
|
||||
if ( results != exp_results ):
|
||||
print("Query:")
|
||||
print(query)
|
||||
print("Expected:")
|
||||
print(exp_results)
|
||||
print("Received:")
|
||||
43
mysql-client-tests/python/pymysql-test.py
Normal file
43
mysql-client-tests/python/pymysql-test.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import pymysql
|
||||
import sys
|
||||
|
||||
QUERY_RESPONSE = [
|
||||
{ "create table test (pk int, value int, primary key(pk))": () },
|
||||
{ "describe test": (
|
||||
('pk', 'int', 'NO', 'PRI', '', ''),
|
||||
('value', 'int', 'YES', '', '', '')
|
||||
) },
|
||||
{ "insert into test (pk, value) values (0,0)": () },
|
||||
{ "select * from test": ((0,0),) }
|
||||
]
|
||||
|
||||
def main():
|
||||
user = sys.argv[1]
|
||||
port = int(sys.argv[2])
|
||||
db = sys.argv[3]
|
||||
|
||||
connection = pymysql.connect(host="127.0.0.1",
|
||||
port=port,
|
||||
user=user,
|
||||
db=db)
|
||||
|
||||
for query_response in QUERY_RESPONSE:
|
||||
query = list(query_response.keys())[0]
|
||||
exp_results = query_response[query]
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(query)
|
||||
results = cursor.fetchall()
|
||||
if ( results != exp_results ):
|
||||
print("Query:")
|
||||
print(query)
|
||||
print("Expected:")
|
||||
print(exp_results)
|
||||
print("Received:")
|
||||
print(results)
|
||||
exit(1)
|
||||
|
||||
connection.close()
|
||||
|
||||
exit(0)
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user