A tiny Migration script

本文介绍了一个使用Groovy语言实现的数据库迁移脚本,该脚本从原始Oracle数据库中读取数据,并将其插入到目标数据库中对应的表里。迁移的数据包括收费项目和项目信息。

import groovy.sql.Sql

class Migration {         
    static getSqlInstance(String orig_or_dest) {
        Sql.newInstance(
            "jdbc:oracle:thin:@asapp:1521:appdb",
            orig_or_dest == 'orig' ? "usr1" : 'usr2',
            orig_or_dest == 'orig' ? "pwd1" : 'pwd2',
            "oracle.jdbc.driver.OracleDriver")
    }

    static migrateChargeItems() {
        def dataset = []
        getSqlInstance('orig').eachRow("select * from A_CHARGETREE"){ row ->
            dataset << [row.id, row.name, row.description, row.parentId, row.leaf]
        }
        dataset.each{item ->
            getSqlInstance('dest').execute("insert into CHARGE_ITEM (id, name, description, parent_id, leaf, version, deleted) values (${item[0]}, ${item[1]}, ${item[2]}, ${item[3]}, ${item[4]?:0}, 1, 0)")
        }
    }

    static migrateProjects() {
        def dataset = []
        getSqlInstance('orig').eachRow("select * from A_PROJECT"){ row ->
            dataset << [row.id, row.name, row.description]
        }
        dataset.each{item ->
            getSqlInstance('dest').execute("insert into PROJECT (id, name, description, version, deleted) values (${item[0]}, ${item[1]}, ${item[2]?:item[1]}, 1, 0)")
        }
    }

    static void main(String[] args) {
        Migration.class.classLoader.rootLoader.addURL( new URL("file:///d:/workspace/timesheet-migration/lib/ojdbc6.jar") )

        migrateChargeItems()
        migrateProjects()
    }
}

tzb@tzb:~/PX4_Firmware$ make px4_sitl_default gazebo -- PX4 version: v1.11.0-beta1 -- PX4 config file: /home/tzb/PX4_Firmware/boards/px4/sitl/default.cmake -- PX4 config: px4_sitl_default -- PX4 platform: posix -- PX4 lockstep: enabled -- cmake build type: RelWithDebInfo -- The CXX compiler identification is GNU 9.4.0 -- The C compiler identification is GNU 9.4.0 -- The ASM compiler identification is GNU -- Found assembler: /usr/bin/cc -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Building for code coverage -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") -- build type is RelWithDebInfo -- PX4 ECL: Very lightweight Estimation & Control Library v1.9.0-rc1-255-g47624a0 -- Configuring done -- Generating done -- Build files have been written to: /home/tzb/PX4_Firmware/build/px4_sitl_default [0/740] git submodule src/drivers/gps/devices [1/740] git submodule src/lib/ecl [7/740] git submodule mavlink/include/mavlink/v2.0 [10/740] git submodule Tools/sitl_gazebo [18/740] Performing configure step for 'sitl_gazebo' -- install-prefix: /usr/local -- The C compiler identification is GNU 9.4.0 -- The CXX compiler identification is GNU 9.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test COMPILER_SUPPORTS_CXX17 -- Performing Test COMPILER_SUPPORTS_CXX17 - Success -- Performing Test COMPILER_SUPPORTS_CXX14 -- Performing Test COMPILER_SUPPORTS_CXX14 - Success -- Performing Test COMPILER_SUPPORTS_CXX11 -- Performing Test COMPILER_SUPPORTS_CXX11 - Success -- Performing Test COMPILER_SUPPORTS_CXX0X -- Performing Test COMPILER_SUPPORTS_CXX0X - Success -- Using C++17 compiler -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.58") found components: system thread filesystem -- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") -- Checking for module 'bullet>=2.82' -- Found bullet, version 2.88 -- Found ccd: /usr/include (found suitable version "2.0", minimum required is "2.0") -- Found fcl: /usr/include (found suitable version "0.5.0", minimum required is "0.3.2") -- Found assimp: /usr/include (found version "5.0.0") -- Found DART: /usr/include (Required is at least version "6.6") found components: dart -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.40.0") found components: thread system filesystem program_options regex iostreams date_time -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.6.1") -- Looking for ignition-math6 -- found version 6.15.1 -- Searching for dependencies of ignition-math6 -- Looking for OGRE... -- OGRE_PREFIX_WATCH changed. -- Checking for module 'OGRE' -- Found OGRE, version 1.9.0 -- Found Ogre Ghadamon (1.9.0) -- Found OGRE: optimized;/usr/lib/x86_64-linux-gnu/libOgreMain.so;debug;/usr/lib/x86_64-linux-gnu/libOgreMain.so -- Looking for OGRE_Paging... -- Found OGRE_Paging: optimized;/usr/lib/x86_64-linux-gnu/libOgrePaging.so;debug;/usr/lib/x86_64-linux-gnu/libOgrePaging.so -- Looking for OGRE_Terrain... -- Found OGRE_Terrain: optimized;/usr/lib/x86_64-linux-gnu/libOgreTerrain.so;debug;/usr/lib/x86_64-linux-gnu/libOgreTerrain.so -- Looking for OGRE_Property... -- Found OGRE_Property: optimized;/usr/lib/x86_64-linux-gnu/libOgreProperty.so;debug;/usr/lib/x86_64-linux-gnu/libOgreProperty.so -- Looking for OGRE_RTShaderSystem... -- Found OGRE_RTShaderSystem: optimized;/usr/lib/x86_64-linux-gnu/libOgreRTShaderSystem.so;debug;/usr/lib/x86_64-linux-gnu/libOgreRTShaderSystem.so -- Looking for OGRE_Volume... -- Found OGRE_Volume: optimized;/usr/lib/x86_64-linux-gnu/libOgreVolume.so;debug;/usr/lib/x86_64-linux-gnu/libOgreVolume.so -- Looking for OGRE_Overlay... -- Found OGRE_Overlay: optimized;/usr/lib/x86_64-linux-gnu/libOgreOverlay.so;debug;/usr/lib/x86_64-linux-gnu/libOgreOverlay.so -- Looking for ignition-math6 -- found version 6.15.1 -- Looking for ignition-transport8 -- found version 8.5.0 -- Searching for dependencies of ignition-transport8 -- Config-file not installed for ZeroMQ -- checking for pkg-config -- Checking for module 'libzmq >= 4' -- Found libzmq , version 4.3.2 -- Found ZeroMQ: TRUE (Required is at least version "4") -- Checking for module 'uuid' -- Found uuid, version 2.34.0 -- Found UUID: TRUE -- Looking for ignition-msgs5 -- found version 5.11.0 -- Searching for dependencies of ignition-msgs5 -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found suitable version "3.6.1", minimum required is "3") -- Looking for ignition-math6 -- found version 6.15.1 -- Checking for module 'tinyxml2' -- Found tinyxml2, version 6.2.0 -- Looking for ignition-msgs5 -- found version 5.11.0 -- Looking for ignition-common3 -- found version 3.17.0 -- Searching for dependencies of ignition-common3 -- Looking for dlfcn.h - found -- Looking for libdl - found -- Found DL: TRUE -- Searching for <ignition-common3> component [graphics] -- Looking for ignition-common3-graphics -- found version 3.17.0 -- Searching for dependencies of ignition-common3-graphics -- Looking for ignition-math6 -- found version 6.15.1 -- Looking for ignition-fuel_tools4 -- found version 4.9.1 -- Searching for dependencies of ignition-fuel_tools4 -- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.68.0") -- Checking for module 'jsoncpp' -- Found jsoncpp, version 1.7.4 -- Found JSONCPP: TRUE -- Checking for module 'yaml-0.1' -- Found yaml-0.1, version 0.2.2 -- Found YAML: TRUE -- Checking for module 'libzip' -- Found libzip, version 1.5.1 -- Found ZIP: TRUE -- Looking for ignition-common3 -- found version 3.17.0 -- Looking for ignition-math6 -- found version 6.15.1 -- Looking for ignition-msgs5 -- found version 5.11.0 -- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3") -- Found OpenCV: /usr (found version "4.2.0") -- Found TinyXML: /usr/lib/x86_64-linux-gnu/libtinyxml.so -- Checking for module 'gstreamer-1.0 >= 1.0' -- Found gstreamer-1.0 , version 1.16.3 -- Checking for module 'gstreamer-base-1.0 >= 1.0' -- Found gstreamer-base-1.0 , version 1.16.3 -- Found GStreamer: GSTREAMER_INCLUDE_DIRS;GSTREAMER_LIBRARIES;GSTREAMER_VERSION;GSTREAMER_BASE_INCLUDE_DIRS;GSTREAMER_BASE_LIBRARIES (Required is at least version "1.0") -- Checking for module 'OGRE' -- Found OGRE, version 1.9.0 -- Building klt_feature_tracker without catkin -- Building OpticalFlow with OpenCV -- Found MAVLink: /home/tzb/PX4_Firmware/mavlink/include (found version "2.0") -- catkin DISABLED -- Found Protobuf: /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread (found version "3.6.1") -- Checking for module 'protobuf' -- Found protobuf, version 3.6.1 -- Gazebo version: 11.15 -- Found GStreamer: adding gst_camera_plugin -- Found GStreamer: adding gst_video_stream_widget -- Configuring done -- Generating done -- Build files have been written to: /home/tzb/PX4_Firmware/build/px4_sitl_default/build_gazebo [586/740] Performing build step for 'sitl_gazebo' [11/100] Generating /home/tzb/PX4_Firm...ls/mb1240-xl-ez4/mb1240-xl-ez4-gen.sdf /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/mb1240-xl-ez4/mb1240-xl-ez4.sdf.jinja -> /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/mb1240-xl-ez4/mb1240-xl-ez4-gen.sdf [12/100] Generating /home/tzb/PX4_Firm..._gazebo/models/px4flow/px4flow-gen.sdf /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/px4flow/px4flow.sdf.jinja -> /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/px4flow/px4flow-gen.sdf [13/100] Generating /home/tzb/PX4_Firm...models/3DR_gps_mag/3DR_gps_mag-gen.sdf /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/3DR_gps_mag/3DR_gps_mag.sdf.jinja -> /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/3DR_gps_mag/3DR_gps_mag-gen.sdf [14/100] Generating /home/tzb/PX4_Firm...s/sitl_gazebo/models/c920/c920-gen.sdf /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/c920/c920.sdf.jinja -> /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/c920/c920-gen.sdf [15/100] Generating /home/tzb/PX4_Firm...models/matrice_100/matrice_100-gen.sdf /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/matrice_100/matrice_100.sdf.jinja -> /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/matrice_100/matrice_100-gen.sdf [16/100] Generating /home/tzb/PX4_Firm...sitl_gazebo/models/sf10a/sf10a-gen.sdf /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/sf10a/sf10a.sdf.jinja -> /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/sf10a/sf10a-gen.sdf [17/100] Generating /home/tzb/PX4_Firm..._gazebo/models/pixhawk/pixhawk-gen.sdf /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/pixhawk/pixhawk.sdf.jinja -> /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/pixhawk/pixhawk-gen.sdf [18/100] Generating /home/tzb/PX4_Firm...s/sitl_gazebo/models/r200/r200-gen.sdf /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/r200/r200.sdf.jinja -> /home/tzb/PX4_Firmware/Tools/sitl_gazebo/models/r200/r200-gen.sdf [19/100] Generating /home/tzb/PX4_Firm...Tools/sitl_gazebo/models/iris/iris.sdf [100/100] Linking CXX shared library libgazebo_imu_plugin.so [739/740] cd /home/tzb/PX4_Firmware/bu...zb/PX4_Firmware/build/px4_sitl_default SITL ARGS sitl_bin: /home/tzb/PX4_Firmware/build/px4_sitl_default/bin/px4 debugger: none program: gazebo model: none world: none src_path: /home/tzb/PX4_Firmware build_path: /home/tzb/PX4_Firmware/build/px4_sitl_default empty model, setting iris as default GAZEBO_PLUGIN_PATH :/home/tzb/PX4_Firmware/build/px4_sitl_default/build_gazebo GAZEBO_MODEL_PATH :/home/tzb/PX4_Firmware/Tools/sitl_gazebo/models LD_LIBRARY_PATH /opt/ros/noetic/lib:/home/tzb/PX4_Firmware/build/px4_sitl_default/build_gazebo empty world, setting empty.world as default gzserver: /usr/include/boost/smart_ptr/shared_ptr.hpp:734: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::event::Connection; typename boost::detail::sp_member_access<T>::type = gazebo::event::Connection*]: Assertion `px != 0' failed. /home/tzb/PX4_Firmware/Tools/sitl_run.sh:行 124: 8222 已放弃 (核心已转储) gzserver "${src_path}/Tools/sitl_gazebo/worlds/empty.world" SITL COMMAND: "/home/tzb/PX4_Firmware/build/px4_sitl_default/bin/px4" "/home/tzb/PX4_Firmware"/ROMFS/px4fmu_common -s etc/init.d-posix/rcS -t "/home/tzb/PX4_Firmware"/test_data INFO [px4] Creating symlink /home/tzb/PX4_Firmware/ROMFS/px4fmu_common -> /home/tzb/PX4_Firmware/build/px4_sitl_default/tmp/rootfs/etc ______ __ __ ___ | ___ \ \ \ / / / | | |_/ / \ V / / /| | | __/ / \ / /_| | | | / /^\ \ \___ | \_| \/ \/ |_/ px4 starting. INFO [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0 INFO [param] selected parameter default file eeprom/parameters_10016 [param] parameter file not found, creating eeprom/parameters_10016 SYS_AUTOCONFIG: curr: 0 -> new: 1 * SYS_AUTOSTART: curr: 0 -> new: 10016 BAT_N_CELLS: curr: 0 -> new: 3 CAL_ACC0_ID: curr: 0 -> new: 1311244 CAL_ACC_PRIME: curr: 0 -> new: 1311244 CAL_GYRO0_ID: curr: 0 -> new: 2294028 CAL_GYRO_PRIME: curr: 0 -> new: 2294028 CAL_MAG0_ID: curr: 0 -> new: 197388 CAL_MAG_PRIME: curr: 0 -> new: 197388 COM_DISARM_LAND: curr: 2.0000 -> new: 0.5000 COM_OBL_ACT: curr: 0 -> new: 2 COM_RC_IN_MODE: curr: 0 -> new: 1 EKF2_ANGERR_INIT: curr: 0.1000 -> new: 0.0100 EKF2_GBIAS_INIT: curr: 0.1000 -> new: 0.0100 COM_ARM_EKF_AB: curr: 0.0017 -> new: 0.0050 EKF2_REQ_GPS_H: curr: 10.0000 -> new: 0.5000 MC_PITCH_P: curr: 6.5000 -> new: 6.0000 MC_PITCHRATE_P: curr: 0.1500 -> new: 0.2000 MC_ROLL_P: curr: 6.5000 -> new: 6.0000 MC_ROLLRATE_P: curr: 0.1500 -> new: 0.2000 MPC_HOLD_MAX_Z: curr: 0.6000 -> new: 2.0000 MPC_Z_VEL_I: curr: 0.1000 -> new: 0.1500 MPC_Z_VEL_P: curr: 0.2000 -> new: 0.6000 MPC_XY_P: curr: 0.9500 -> new: 0.8000 MPC_XY_VEL_P: curr: 0.0900 -> new: 0.2000 MPC_XY_VEL_D: curr: 0.0100 -> new: 0.0160 MPC_SPOOLUP_TIME: curr: 1.0000 -> new: 0.5000 MPC_TKO_RAMP_T: curr: 3.0000 -> new: 1.0000 NAV_ACC_RAD: curr: 10.0000 -> new: 2.0000 NAV_DLL_ACT: curr: 0 -> new: 2 RTL_DESCEND_ALT: curr: 30.0000 -> new: 5.0000 RTL_LAND_DELAY: curr: -1.0000 -> new: 5.0000 RTL_RETURN_ALT: curr: 60.0000 -> new: 30.0000 SDLOG_MODE: curr: 0 -> new: 1 SDLOG_PROFILE: curr: 3 -> new: 131 SDLOG_DIRS_MAX: curr: 0 -> new: 7 SENS_BOARD_X_OFF: curr: 0.0000 -> new: 0.0000 SENS_DPRES_OFF: curr: 0.0000 -> new: 0.0010 TRIG_INTERFACE: curr: 4 -> new: 3 * RTL_DESCEND_ALT: curr: 5.0000 -> new: 10.0000 * RTL_LAND_DELAY: curr: 5.0000 -> new: 0.0000 PWM_MAX: curr: 2000 -> new: 1950 PWM_MIN: curr: 1000 -> new: 1075 GPS_UBX_DYNMODEL: curr: 7 -> new: 6 * SYS_AUTOCONFIG: curr: 1 -> new: 0 INFO [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes INFO [simulator] Waiting for simulator to accept connection on TCP port 4560 Gazebo multi-robot simulator, version 11.15.1 Copyright (C) 2012 Open Source Robotics Foundation. Released under the Apache 2 License. http://gazebosim.org # # ####### ####### ### ##### ####### ## # # # # # # # # # # # # # # # # # # # # # # # # # ##### # # # # # # # # # # ## # # # # # # # # # ####### # ### ##### ####### This version of Gazebo, now called Gazebo classic, reaches end-of-life in January 2025. Users are highly encouraged to migrate to the new Gazebo using our migration guides (https://gazebosim.org/docs/latest/gazebo_classic_migration/) [Msg] Waiting for master. [Err] [ConnectionManager.cc:121] Failed to connect to master in 30 seconds. [Err] [gazebo_shared.cc:106] Unable to initialize transport. [Err] [gazebo_client.cc:56] Unable to setup Gazebo ^A
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值