Esempio n. 1
0
    def _get_table_names(self, db_file_path, tables):
        rtn = {}
        with sql.connect(db_file_path) as con:

            def try_name(name):
                try:
                    con.execute("Select * from [%s]" % name)
                except:
                    return False
                return True

            for table in tables:
                rtn[table] = [
                    t for t in all_underscore_replacements(table)
                    if try_name(t)
                ]
                verify(
                    len(rtn[table]) <= 1,
                    "Duplicate tables found for table %s in SQLite file %s" %
                    (table, db_file_path))
                if rtn[table]:
                    rtn[table] = rtn[table][0]
                else:
                    rtn.pop(table)
        return rtn
Esempio n. 2
0
    def _get_table_names(self, db_file_path, tables):
        rtn = {}
        with _connect(_connection_str(db_file_path)) as con:

            def try_name(name):
                with con.cursor() as cur:
                    try:
                        cur.execute("Select * from [%s]" % name)
                    except:
                        return False
                return True

            for table in tables:
                rtn[table] = [
                    t for t in all_underscore_replacements(table)
                    if try_name(t)
                ]
                verify(
                    len(rtn[table]) >= 1,
                    "Unable to recognize table %s in MS Access file %s" %
                    (table, db_file_path))
                verify(
                    len(rtn[table]) <= 1,
                    "Duplicate tables found for table %s in MS Access file %s"
                    % (table, db_file_path))
                rtn[table] = rtn[table][0]
        return rtn
Esempio n. 3
0
 def _get_table_names(self, con):
     rtn = {}
     def try_name(name):
         try :
             con.execute("Select * from [%s]"%name)
         except :
             return False
         return True
     for table in self.pan_dat_factory.all_tables:
         rtn[table] = [t for t in all_underscore_replacements(table) if try_name(t)]
         verify(len(rtn[table]) >= 1, "Unable to recognize table %s" % table)
         verify(len(rtn[table]) <= 1, "Multiple possible tables found for table %s" % table)
         rtn[table] = rtn[table][0]
     return rtn