"""
To improve my testing productivity, i need to organise all testing files in test folder.
I create var use_package to control what kind of codes i'm testing, for eg.
if the value is False, I'm executing copython codes from my working folder, while True
I'm executing copython codes from the site_packages
You should remove the four lines below .
"""
use_package = False
if use_package is False:
    import sys
    sys.path.insert(0, r"e:\documents\visual studio 2017\projects\copython")

import copython

if __name__ == "__main__":
    # drop target table (or comment the two lines below to append data into an existing table)
    conn_str = "DRIVER={ODBC Driver 11 for SQL Server};SERVER=LATITUDE;PORT=1443;DATABASE=Test;UID=user_name;PWD=password;"
    copython.drop_table(conn_str, "dbo", "countries")

    config_path = r"E:\Documents\Visual Studio 2017\Projects\copython\test\_cf_load_oracle_table_into_mssql.xml"
    # call copython.copy_data
    res = copython.copy_data(config_path, debug=True)
    print("res={}".format(res))
Пример #2
0
    import sys
    sys.path.insert(0, r"e:\documents\visual studio 2017\projects\copython")
"""
UNDER DEVELOPMENT
"""
"""
csv sample data is the one of the gtfs files format belong to Queensland Government Australia.
I download the file from the following website.
https://gtfsrt.api.translink.com.au/
"""

import copython

if __name__ == "__main__":
    # drop target table (or comment drop_table below to append data into existing tables)
    conn_str = "DRIVER={ODBC Driver 11 for SQL Server};SERVER=LATITUDE;PORT=1443;DATABASE=Test;UID=user_name;PWD=password;"
    copython.drop_table(conn_str, "dbo", "agency")
    copython.drop_table(conn_str, "dbo", "calendar")
    copython.drop_table(conn_str, "dbo", "calendar_dates")
    copython.drop_table(conn_str, "dbo", "routes")
    copython.drop_table(conn_str, "dbo", "shapes")
    copython.drop_table(conn_str, "dbo", "stop_times")
    copython.drop_table(conn_str, "dbo", "stops")
    copython.drop_table(conn_str, "dbo", "trips")

    config_path = r"E:\Documents\Visual Studio 2017\Projects\copython\test\_cf_load_multi_csv_into_mssql.xml"
    #config_path = r"E:\Documents\Visual Studio 2017\Projects\copython\test\_cf_template_dbo_agency.xml"
    # call copython.copy_data
    res = copython.copy_data(config_path, debug=True)
    print("res={}".format(res))
if use_package is False:
    import sys
    sys.path.insert(0, r"C:\Users\60145210\Documents\Projects\copython")
"""
csv sample data is the one of the gtfs files format belong to Queensland Government Australia.
I download the file from the following website.
https://gtfsrt.api.translink.com.au/
"""

import copython
from copython import copyconf

if __name__ == "__main__":
    # drop target table (or comment the two lines below to append data into an existing table)
    conn_str = "DRIVER={ODBC Driver 13 for SQL Server};SERVER=EHL5CD8434KLM;PORT=1443;DATABASE=Test;UID=tester1;PWD=password;"
    copython.drop_table(conn_str, "dbo", "routes")

    #----------------------------------------
    # start writing a simple programmable copy
    #----------------------------------------

    # create a CopyConf object with None arg (no config file passed in) and fill up its attributes
    cc = copyconf.CopyConf()
    cc.description = "copy csv file into mssql"  # description of this copy

    # create a Copy object and define its source/target type
    c = copyconf.Copy("routes")
    c.source_type = "csv"
    c.target_type = "sql_table"

    # create a source object (in this case a csv object) and fill up its attributes
"""
To improve my testing productivity, i need to organise all testing files in test folder.
I create var use_package to control what kind of codes i'm testing, for eg.
if the value is False, I'm executing copython codes from my working folder, while True
I'm executing copython codes from the site_packages
You should remove the four lines below .
"""
use_package = False
if use_package is False:
    import sys
    sys.path.insert(0, r"e:\documents\visual studio 2017\projects\copython")
"""
csv sample data is the one of the gtfs files format belong to Queensland Government Australia.
I download the file from the following website.
https://gtfsrt.api.translink.com.au/
"""

import copython

if __name__ == "__main__":
    # drop target table (or comment the two lines below to append data into an existing table)
    conn_str = "DRIVER={PostgreSQL Unicode(x64)};SERVER=localhost;PORT=5432;DATABASE=Test;UID=user_name;PWD=password"
    copython.drop_table(conn_str, "public", "seq_routes")

    config_path = r"E:\Documents\Visual Studio 2017\Projects\copython\test\_cf_load_csv_into_pgsql.xml"
    # call copython.copy_data
    res = copython.copy_data(config_path, debug=True)
    print("res={}".format(res))
Пример #5
0
"""
To improve my testing productivity, i need to organise all testing files in test folder.
I create var use_package to control what kind of codes i'm testing, for eg.
if the value is False, I'm executing copython codes from my working folder, while True
I'm executing copython codes from the site_packages
You should remove the four lines below if you have to.
"""
use_package = False
if use_package is False:
    import sys
    sys.path.insert(0,r"e:\documents\visual studio 2017\projects\copython")


import copython

if __name__=="__main__":
    """
    copy mysql world.city table into mssql dbo.city
    """
    # drop target table (or comment the two lines below to append data into an existing table)
    conn_str = "DRIVER={ODBC Driver 11 for SQL Server};SERVER=LATITUDE;PORT=1443;DATABASE=Test;UID=user_name;PWD=password;"
    copython.drop_table(conn_str,"dbo","city")
    
    config_path = r"E:\Documents\Visual Studio 2017\Projects\copython\test\_cf_load_mssql_table_into_mssql.xml"
    # call copython.copy_data
    res = copython.copy_data(config_path,debug=True)
    print("res={}".format(res))