반응형
directory scan][ 지정 directory 내의 모든 sqlite 파일 select 해보기
■ 사용법
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# write by kyoung chip ,jang | |
# python 2.7 | |
# | |
import os | |
import sys | |
import sqlite3 | |
def get_files( dir ): | |
x = 0 | |
for pack in os.walk(dir): | |
for f in pack[2]: | |
yield pack[0] + "/" + f , f | |
x += 1 | |
print ( ("Dir: %s , there are %s of files") % ( dir, str(x) ) ) | |
def select_db( dbfile ) : | |
conn = sqlite3.connect( dbfile ) | |
c = conn.cursor() | |
for raw in c.execute("SELECT * FROM balance") : | |
print(raw ) | |
c.close() | |
if __name__ == '__main__': | |
for full_path , file_name in get_files('./0x02-key-db') : | |
print("\n\n") | |
print( "full path = %s , file_name = %s " % ( full_path , file_name ) ) | |
select_db( full_path ) |

반응형
'Python > 0x10-sqlite' 카테고리의 다른 글
sqlite ][ where절 사용 해보기 (0) | 2019.09.02 |
---|---|
sqlite ][ select 해보기 (0) | 2019.08.27 |