查询sqlite数据库

import sqlite3

import os

for parent, dirnames, filenames in os.walk("./aa/"):
    for str in filenames:
        conn = sqlite3.connect("./aa/" + str)
        cursor = conn.cursor()
        cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name")
        values = cursor.fetchall()
        for str2 in values:
            one_big_string = ''.join(str2)
            one_big_string.rstrip('(\'')
            one_big_string.rstrip('\',)')
            cursor.execute("PRAGMA table_info(" + one_big_string + ")")
            for tuple in cursor.fetchall():  # 3800  4999
                cursor.execute("SELECT * FROM " + one_big_string + " WHERE " + tuple[1] + " LIKE '%需要查询的内容%'")
                vv = cursor.fetchall()
                if len(vv) != 0:
                    print(str)
                    print(one_big_string)
                    print(vv)
                    print("")
print("")

你可能感兴趣的:(查询sqlite数据库)