ó à@Qc@s–ddlZddlZddlZddlZddlmZmZddlmZddlm Z defd„ƒYZ defd„ƒYZ dS( iÿÿÿÿN(t WizardPagetWizardProgressPage(t DataMigrator(trequest_passwordt SetupMainViewcBsGeZd„Zd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs’tjtjjƒtjƒ}|j|ƒ|jt||dƒjƒƒ|j ƒrŽt||dƒj |j ƒƒt ||dt ƒndS(Nt_entryt_check_duplicate(tmformstnewFileChoosertFormt main_formtSaveFilet set_titletset_pathtgetattrtget_string_valuet run_modalt set_valuetget_pathtsetattrtFalse(tselftoptionttitletform((s%..\modules\migration_data_transfer.pyt _browse_filess     c s]tjƒ}|j|ƒ|j|ttƒtjtƒ}|jdƒ|jtj|ƒttƒtj ƒ}|j ˆˆ‡fd†ƒ|j|ttƒ|j ||d„ƒtj ƒ} | jdƒ| j ˆ|‡fd†ƒ|j| ttƒ|j|ttƒ|j tƒtˆˆdtƒtˆˆd|ƒtˆˆd|ƒdS( Nicst|ˆdtƒS(NR(RtTrue(RR(tname(s%..\modules\migration_data_transfer.pyt+scSs|j|jƒƒS(N(t set_enabledt get_active(tboxtcheck((s%..\modules\migration_data_transfer.pyR-ss Browse...csˆj||ƒS(N(R(RR(R(s%..\modules\migration_data_transfer.pyR0sRt _checkboxR(Rt newCheckBoxtset_texttaddRRtnewBoxt set_spacingtnewLabelt newTextEntrytadd_changed_callbacktadd_clicked_callbackt newButtonRR( RRRtcaptiont path_captiontbrowser_captionR tfile_boxt file_entrytbutton((RRs%..\modules\migration_data_transfer.pyt_add_script_checkbox_option#s&       cCsYtj||dƒ|jj|ddƒtjdƒ}|jj|tt ƒtj tj ƒ}|j dƒ|jj|tt ƒtj tƒ}|j|ƒ|jdƒtjƒ|_|jjdƒ|j|jtt ƒ|jtjdƒtt ƒtjdkr(|j|d d d d ƒn|j|d d dd ƒtj tj ƒ}|j dƒ|jj|tt ƒtj tƒ|_|jjdƒ|jjdƒ|j|jƒtjƒ|_|jjdƒ|jj|jtt ƒtj t ƒ}|jdƒ|jtjdƒtt ƒtjƒ|_|jjdƒ|jjddƒ|j|jtt ƒtjddƒ}|jtjƒ|j|t t ƒ|jj|tt ƒtjƒ|_|jjdƒ|jj|jtt ƒtj tj ƒ|_|jj dƒ|jj|jt t ƒtj tƒ}|jdƒ|jdƒtjdƒ}|jtjƒ|j|tt ƒtj tj!ƒ|_"|j"j#tj$ddtƒ|j"j#tj%ddt ƒ|j"j#tj%dd tƒ|j"j&ƒ|j|j"t t ƒ|jj|ƒ|j"j'|j(ƒt|_)|jj*tƒdS(!NsData Transfer SetupsDATA MIGRATIONssSelect options for the copy of the migrated schema tables in the target MySQL server and click [Next >] to execute.s Data Copyi s)Online copy of table data to target RDBMSttwin32t copy_scripts4Create a batch file to copy the data at another times Batch File:sSave Ass=Create a shell script to copy the data from outside WorkbenchsShell Script File:tOptionsis@Truncate target tables (ie. delete contents) before copying datas Worker taskst2i2iÿÿÿÿs@Number of tasks to use for data transfer. Each task will open a sPconnection to both source and target RDBMSs to copy table rows. Default value 2.s"Enable debug output for table copysTables to CopysòYou can limit the number of rows to be copied for certain tables. Tables that are referenced by foreign keys from other tables cannot be limited, unless data copy from the referencing tables is also disabled. All tables are copied by default.tTableiÈs Limit CopyidsReferencing Tablesiô(+Rt__init__tmaintadd_wizard_pageRR'tcontentR$RRtnewPaneltTitledBoxPanelR R%t set_paddingR"t_copy_dbR#tsystplatformR2t options_boxR&t _truncate_dbR(t _worker_countRtset_sizet set_styletSmallHelpTextStylet _debug_copyt_advanced_paneltnewTreeNodeViewt TreeDefaultt_treet add_columntIconStringColumnTypetStringColumnTypet end_columnstset_cell_edited_callbackt _cell_editedt _advbox_showntshow(RR:tlabeltpanelRthboxtl((s%..\modules\migration_data_transfer.pyR9:s|            cCs1|jjƒ}y+t|ƒ}|dkr9tdƒ‚nWn$tjjdddddƒdSX||jjj j d<|j j ƒr¨|j jƒ|jjj j d      ' ," ( t__name__t __module__RR2R9RwR‡RƒRS(((s%..\modules\migration_data_transfer.pyRs   ] G  $tTransferMainViewcBsteZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z RS( cCsŽtj||ddtƒ|jj|ddƒ|j|jdƒ|j|jdƒ|_|j |j dƒ|_ |j |j dƒ|_ dS(NsBulk Data Transfertuse_private_message_handlingsDATA MIGRATIONs!Prepare information for data copys!Create shell script for data copys Determine number of rows to copysCopy data to target RDBMS(RR9RR:R;tadd_taskt _prepare_copyt_create_copy_scriptt_copy_script_tasktadd_threaded_taskt _count_rowst_migrate_task1t _migrate_datat_migrate_task2(RR:((s%..\modules\migration_data_transfer.pyR9Bs cCs1|r|jjjj}|jddƒ}|jj|dkƒ|jdtƒsd|jdtƒr‡|j jt ƒ|j jt ƒn |j jtƒ|j jtƒt|_ i|_ |jdtƒr·|jjjj}|dkrt|jjjjƒ}n|jjjj}|dkr|jjjjj|jjjjjkr|jjjjjd|jjjjjdkrŠ|}qŠqn|dkrÃt|jjjjƒ}qÃn d}d}t||jjjj|jjjj||jjjj|ƒ|_|jjj|j_ntj||ƒdS(NR\R]tGenerateDumpScripttuserName(R:ReRfRgRR¦R·RRRºRR¼t_migrating_datat_progress_per_tabletmigrationSourcetpasswordRt connectionRŽthostIdentifiertparameterValuesRt _transferertwbcopytables_pathtcopytable_pathRR‡(RRˆtoptionsR5tsource_passwordttarget_password((s%..\modules\migration_data_transfer.pyR‡Ms:$    *2 cCs|jtƒtj|ƒdS(N(tresetRRtgo_back(R((s%..\modules\migration_data_transfer.pyRÍss cCs tj|ƒS(N(Rt update_status(R((s%..\modules\migration_data_transfer.pyRÎxscCs¢|jjjj}|jjjjd}|jjjjjjj }|jjjj ƒ}|jjj j ƒ}i|_ x%|D]}d}xZ|jD]O}|j|jjkr“x-|jD]"} | j|jkr¸| }Pq¸q¸WPq“q“W|s|jd|j|jfƒq}n|rn|j|jjjƒ} |jrB|j} q•|j|jjƒd|j|jƒ} n'|j|jjƒ} |j|jƒ} |j|jjƒ} |j|jƒ} i|d6| d6| d6| d6| d6|d 6|j | d|  %s RÏRÐRÑRÒRÕt's ECHO %s >> %ss t;t s '%s's %ssš --source-password="%arg_source_password%" --target-password="%arg_target_password%" --table-file="%table_file%" %arg_truncate_target% %arg_debug_output%s0REM Removes the file with the tabla definitions sDEL %s s!# Source and target DB passwords sarg_source_password= sarg_target_password= s:# Uncomment the following options according to your needs s9# Whether target tables should be truncated before copy s'#arg_truncate_target=--truncate-target s# Enable debugging output s%#arg_debug_output=--log-level=debug3 sy --source-password="$arg_source_password" --target-password="$arg_target_password" $arg_truncate_target $arg_debug_outputs --table '%s' '%s' '%s' '%s' '%s'sTable copy script written to %s(R:ReRfRgtopenRARBtostchmodtwriteRÁRÃRÄRÖRœR,RŽRÙtvaluesRsRßRšRÇRÆthelper_basic_arglisttcloset send_info( RtpathtfRíRŠR~tfieldstlinetargtopt((s%..\modules\migration_data_transfer.pyR¶´s   #&                           9  cCsŽ|jdƒ|jj|jƒ}|jd|t|jƒfƒxE|jjƒD]4}|jd|d|d|jddƒfƒqRWdS(Ns$Counting number of rows in tables...s-%i total rows in %i tables need to be copied:s - %s.%s: %sRÏRÐt row_countterror(RøRÆtcount_table_rowsRÙR•RõR(Rttotalttask((s%..\modules\migration_data_transfer.pyR¹s   c Csed}t|jƒ}x>|jjƒD]-}||jddƒ7}|j|dƒq%W|jdƒ|jrT|jjjj jddƒ}|jdƒt |_ t |_ z|jj||jƒ}Wdt |_ t |_ X|jdƒ|jdƒd}x|jjƒD] }|j|d d |d dƒ}|jddƒ}|rZ|\} } n d} t } | ró| |kró|d }d |d |d f} d| ||d|df} |jd| | ƒ|jd|d |d | |fƒq |jd|d |d | |fƒq W|jd||fƒ|jjratjdƒ‚qan |jdƒdS(NiRÿRÓR3R[isMigrating data...sData copy results:RÑRŒRÒis%s.%ss+Succeeded : copied %s of %s rows from %s.%sRÏRÐs,- %s.%s has succeeded (%s of %s rows copied)s)- %s.%s has FAILED (%s of %s rows copied)s!%i tables of %i were fully copiedsCanceled by usersNothing to be done(R•RÙRõRtcreate_transfer_logRøR:ReRfRgRt_log_progress_textRR¿RÆt migrate_dataR¦t add_log_entryt interruptedRut UserInterrupt( RRt table_countRt thread_counttsucceeded_taskst fully_copiedtinfoRÿtokRnRÒtmessage((s%..\modules\migration_data_transfer.pyR»sH         " () cCs|jdƒdS(NsKChecking if number of rows copied to target tables matches source tables...(Rø(R((s%..\modules\migration_data_transfer.pyt _verify_copyRscCs“tjjƒ}||_|jjjjƒ}|j|jj j ƒ}|j|jj ƒ}d||f|_ ||_|jjj j j |ƒdS(Ns%s.%s(Rutclassest GrtLogObjectt logObjectR:ReRŽRØRÜRœRRftdataTransferLogRs(RRÒtlogRãt logSchematlogTable((s%..\modules\migration_data_transfer.pyRVs  cCs4x-|jjjjD]}||jkr|SqWdS(N(R:ReRfRR(RRÒR((s%..\modules\migration_data_transfer.pytget_log_objectcscCsD|j|ƒ}tjjƒ}||_||_|jj|ƒdS(N(RRuRt GrtLogEntryt entryTypeRtentriesRs(RttypeRÒRRtentry((s%..\modules\migration_data_transfer.pyRhs   (R°R±R9R‡RÍRÎRµR¶R¹R»RRRR(((s%..\modules\migration_data_transfer.pyR²As &   8 ` 5  ( RARuRRòt workbench.uiRRRtmigration_source_selectionRRR²(((s%..\modules\migration_data_transfer.pyts    ÿ(