Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.
This repository was archived by the owner on May 17, 2024. It is now read-only.

MySQL driver querying information_schema with a table_schema value of the user instead of the database #102

Closed
@DominicChiampi

Description

@DominicChiampi

The first queries that data-diff performs is getting the columns from the specified table; however, the query is using the user as the TABLE_SCHEMA instead of the database.

data-diff --debug mysql://root:root_password@mysql5:3306/coolname Transaction mysql://user:user_password/@mysql:3306/coolname Transaction
[11:33:45] DEBUG - Running SQL (MySQL): SELECT column_name, data_type, datetime_precision, numeric_precision, numeric_scale FROM information_schema.columns WHERE table_name = 'Transaction' AND table_schema = 'root'
[11:33:45] DEBUG - Running SQL (MySQL): SELECT column_name, data_type, datetime_precision, numeric_precision, numeric_scale FROM information_schema.columns WHERE table_name = 'Transaction' AND table_schema = 'user'

In MySQL's information schema the TABLE_SCHEMA is the database, not the user
https://dev.mysql.com/doc/mysql-infoschema-excerpt/8.0/en/information-schema-columns-table.html

MySQL [(none)]> select TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, engine from information_schema.tables where table_name = 'Transaction'\G
*************************** 1. row ***************************
TABLE_SCHEMA: coolname
  TABLE_NAME: Transaction
  TABLE_TYPE: BASE TABLE
      ENGINE: InnoDB
1 row in set (0.003 sec)

This is causing data-diff to fail to find the table and columns so data-diff cannot function

RuntimeError: MySQL: Table 'Transaction' does not exist, or has no columns

Versions:

root@22b19e3a116f:/# python3 --version
Python 3.7.3
root@22b19e3a116f:/# pip3 list
Package                Version
---------------------- ---------
asn1crypto             0.24.0
awscli                 1.16.113
botocore               1.12.103
certifi                2018.8.24
chardet                3.0.4
click                  8.1.3
colorama               0.4.5
commonmark             0.9.1
cryptography           2.6.1
data-diff              0.2.0
docutils               0.14
dsnparse               0.1.15
entrypoints            0.3
idna                   2.6
importlib-metadata     4.11.4
jmespath               0.9.4
keyring                17.1.1
keyrings.alt           3.1.1
mysql-connector-python 8.0.29
pip                    18.1
protobuf               4.21.1
pyasn1                 0.4.2
pycrypto               2.6.1
Pygments               2.12.0
PyGObject              3.30.4
python-dateutil        2.7.3
pyxdg                  0.25
PyYAML                 3.13
requests               2.21.0
rich                   10.16.2
roman                  2.0.0
rsa                    4.0
runtype                0.2.6
s3transfer             0.2.0
SecretStorage          2.3.1
setuptools             40.8.0
six                    1.12.0
typing-extensions      4.2.0
urllib3                1.24.1
wheel                  0.32.3
zipp                   3.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions