|
|
@ -122,8 +122,7 @@ def db_delete(conn, cursor, db):
|
|
|
|
|
|
|
|
|
|
|
|
def db_import(conn, cursor, module, db, target):
|
|
|
|
def db_import(conn, cursor, module, db, target):
|
|
|
|
if os.path.isfile(target):
|
|
|
|
if os.path.isfile(target):
|
|
|
|
backup = open(target, 'r')
|
|
|
|
with open(target, 'r') as backup:
|
|
|
|
try:
|
|
|
|
|
|
|
|
sqlQuery = "USE [%s]\n" % db
|
|
|
|
sqlQuery = "USE [%s]\n" % db
|
|
|
|
for line in backup:
|
|
|
|
for line in backup:
|
|
|
|
if line is None:
|
|
|
|
if line is None:
|
|
|
@ -135,8 +134,6 @@ def db_import(conn, cursor, module, db, target):
|
|
|
|
sqlQuery += line
|
|
|
|
sqlQuery += line
|
|
|
|
cursor.execute(sqlQuery)
|
|
|
|
cursor.execute(sqlQuery)
|
|
|
|
conn.commit()
|
|
|
|
conn.commit()
|
|
|
|
finally:
|
|
|
|
|
|
|
|
backup.close()
|
|
|
|
|
|
|
|
return 0, "import successful", ""
|
|
|
|
return 0, "import successful", ""
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return 1, "cannot find target file", "cannot find target file"
|
|
|
|
return 1, "cannot find target file", "cannot find target file"
|
|
|
|