Created
June 21, 2018 17:42
-
-
Save ArionMiles/40df3c5f31521ab1419971bef59307a6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'''Copies data of one table from DB1 to same table in DB2''' | |
from models_old import Chat as Chat1 | |
from database_old import init_db as init1 | |
from database import init_db as init2, db_session as db_s2 | |
from models import Chat as Chat2 | |
def main(): | |
init1() #Start DB1 | |
init_db() #Start DB2 | |
chat1_query = Chat1.query.all() | |
for chat1 in chat1_query: | |
PID1 = chat1.PID | |
password1 = chat1.password | |
chatID1 = chat1.chatID | |
record = Chat2(PID=PID1, | |
password=password1, | |
chatID=chatID1) | |
db_s2.add(record) | |
db_s2.commit() # Commit changes after every record has been migrated | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment