Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

case sensitive issue how to solve it #67

Open
Azhar3004 opened this issue Sep 29, 2022 · 0 comments
Open

case sensitive issue how to solve it #67

Azhar3004 opened this issue Sep 29, 2022 · 0 comments

Comments

@Azhar3004
Copy link

#58 i am facing some problem to solve this issue when i run this code it accepts only exact table name for example we have table whose name is 'class' and when i write table name like (Class,CLASS,classes) it is not giving me the output although i am using [flags=re.IGNORRECASE] how to solve this issue please help me.

def create_table(self, table_string):
    lines = table_string.split("\n")
    table = Table()
    for line in lines:
        if 'TABLE' in line:
            table_name = re.search("`(\w+)`", line,flags=re.IGNORECASE)
            table.name = table_name.group(1)
            if self.thesaurus_object is not None:
                table.equivalences = self.thesaurus_object.get_synonyms_of_a_word(table.name)
        elif 'PRIMARY KEY' in line:
            primary_key_columns = re.findall("`(\w+)`", line,flags=re.IGNORECASE)
            for primary_key_column in primary_key_columns:
                table.add_primary_key(primary_key_column)
        else:
            column_name = re.search("`(\w+)`", line,flags=re.IGNORECASE)
            if column_name is not None:
                column_type = self.predict_type(line)
                if self.thesaurus_object is not None:
                    equivalences = self.thesaurus_object.get_synonyms_of_a_word(column_name.group(1))
                else:
                    equivalences = []
                table.add_column(column_name.group(1), column_type, equivalences)
    return table

def alter_table(self, alter_string):
    lines = alter_string.replace('\n', ' ').split(';')
    for line in lines:
        if 'PRIMARY KEY' in line:
            table_name = re.search("TABLE `(\w+)`", line,flags=re.IGNORECASE).group(1)
            table = self.get_table_by_name(table_name)
            primary_key_columns = re.findall("PRIMARY KEY \(`(\w+)`\)", line,flags=re.IGNORECASE)
            for primary_key_column in primary_key_columns:
                table.add_primary_key(primary_key_column)
        elif 'FOREIGN KEY' in line:
            table_name = re.search("TABLE `(\w+)`", line,flags=re.IGNORECASE).group(1)
            table = self.get_table_by_name(table_name)
            foreign_keys_list = re.findall("FOREIGN KEY \(`(\w+)`\) REFERENCES `(\w+)` \(`(\w+)`\)", line,flags=re.IGNORECASE)
            for column, foreign_table, foreign_column in foreign_keys_list:
                table.add_foreign_key(column, foreign_table, **foreign_column)**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant