ajib6ept
6/7/2014 - 11:33 AM

Конвертируем microsoft access в sqlite

Конвертируем microsoft access в sqlite

import sys
import subprocess

ACCEESSDB = 'books1.mdb'
SQLITEDB = 'out.db'

def main():
    subprocess.Popen(['mdb-schema %s | sqlite3 %s' % (ACCEESSDB, SQLITEDB)], shell=True).communicate()
    table_names = subprocess.Popen(["mdb-tables %s" % ACCEESSDB], stdout=subprocess.PIPE, shell=True).communicate()[0].rstrip()
    tables = table_names.split(' ')
    for table in tables:
        print table
        subprocess.Popen('mdb-export -I mysql %s %s | sqlite3 %s' % (ACCEESSDB, table, SQLITEDB), shell=True).communicate()

if __name__ == '__main__':
    main()