def __init__(self, 
              protocol = None,
              host_name = None,
              user_name = None,
              password = None,
              database_name = None,
              database_configuration = None):
     if database_name is None:
         database_name = 'services'
     DatabaseConfiguration.__init__(self,
                           protocol = protocol,
                           host_name = host_name,
                           user_name = user_name,
                           password = password,
                           database_name = database_name,
                           database_configuration = database_configuration)
 def __init__(self, 
              protocol = get_default_database_engine(),
              host_name = None,
              user_name = None,
              password = None,
              database_name = None,
              database_configuration = None):
     self.protocol = protocol
     DatabaseConfiguration.__init__(self,
                           protocol = protocol,
                           host_name = host_name,
                           user_name = user_name,
                           password = password,
                           database_name = database_name,
                           database_configuration = database_configuration,
                           test = True)
 def __init__(self,
              protocol=None,
              host_name=None,
              user_name=None,
              password=None,
              database_name=None,
              database_configuration=None):
     if database_name is None:
         database_name = 'services'
     DatabaseConfiguration.__init__(
         self,
         protocol=protocol,
         host_name=host_name,
         user_name=user_name,
         password=password,
         database_name=database_name,
         database_configuration=database_configuration)
Esempio n. 4
0
        'tsv': ['append_type_info'],
        'csv': ['append_type_info'],
        'dat': ['append_type_info'],
    }
    create_output_directory = ['hdf5', 'tab', 'tsv', 'csv', 'dat', 'dbf']
    if (directory is None or output_file is None or table_name is None):
        parser.print_help()
        sys.exit(1)
    storage_intype = args[0]
    storage_outtype = args[1]

    if storage_intype == 'sql':
        database_name = directory
        db_server = DatabaseServer(
            DatabaseConfiguration(
                database_name=database_name,
                database_configuration=options.database_configuration))
        db = db_server.get_database(database_name)
        directory = db

    if storage_outtype == 'sql':
        database_name = output_file
        db_server = DatabaseServer(
            DatabaseConfiguration(
                database_name=database_name,
                database_configuration=options.database_configuration))
        if not db_server.has_database(database_name):
            db_server.create_database(database_name)
        db = db_server.get_database(database_name)
        output_file = db
Esempio n. 5
0
    def test__output_types(self):
        output_types = ['csv', 'tab', 'fixed_field']
        try:
            import dbfpy
        except ImportError:
            pass
        else:
            output_types.append('dbf')

        try:

            test_db_name = 'test_db_for_indicator_framework'
            database_config = DatabaseConfiguration(
                database_name=test_db_name,
                test=True,
            )

            server = DatabaseServer(database_config)
            server.drop_database(database_name=test_db_name)
            server.create_database(database_name=test_db_name)

        except:
            has_sql = False
        else:
            has_sql = True
            output_types.append('sql')

        indicator = Indicator(dataset_name='test',
                              attribute='opus_core.test.attribute')

        maker = Maker(project_name='test', test=True)
        computed_indicators = maker.create_batch(
            indicators={'attr1': indicator}, source_data=self.source_data)

        for output_type in output_types:
            kwargs = {}
            if output_type == 'sql':
                kwargs['storage_location'] = database_config
            elif output_type == 'fixed_field':
                kwargs[
                    'fixed_field_format'] = '<fixed_field><field name="attribute_1980" format="10f" /></fixed_field>'

            table = Table(
                indicator_directory=self.source_data.get_indicator_directory(),
                output_type=output_type,
                **kwargs)
            table._create_input_stores(self.source_data.years)
            viz_result = table.visualize(
                indicators_to_visualize=['attr1'],
                computed_indicators=computed_indicators)[0]
            if output_type in ['csv', 'dbf', 'tab', 'fixed_field']:
                self.assertTrue(
                    os.path.exists(
                        os.path.join(
                            viz_result.storage_location,
                            viz_result.table_name + '.' +
                            viz_result.file_extension)))
            elif output_type == 'sql':
                self.assertTrue(server.has_database(test_db_name))
                db = server.get_database(test_db_name)
                self.assertTrue(
                    db.table_exists(table_name=viz_result.table_name))
        if has_sql:
            server.drop_database(database_name=test_db_name)
#from urbansim.configs.base_config_zone import run_configuration
from urbansim.configs.cache_baseyear_configuration import CacheBaseyearConfiguration
from urbansim.configurations.creating_baseyear_cache_configuration import CreatingBaseyearCacheConfiguration


cache_configuration = CacheBaseyearConfiguration()
my_cache_config = CreatingBaseyearCacheConfiguration(
        cache_directory_root = '/tmp/urbcache/sandbox_runs/zones',
        unroll_gridcells = True,
        cache_from_database = True,
        baseyear_cache = BaseyearCacheConfiguration(
            existing_cache_to_copy = '/urbansim_cache/psrc_zone',
            years_to_cache = range(1996,2000),
            ),
        tables_to_cache = tables_to_cache().get_tables_to_cache(),
        tables_to_cache_nchunks = {
            'gridcells':5,
            },
    )
cache_configuration['creating_baseyear_cache_configuration'] = my_cache_config
my_configuration = {
    'remove_cache': False, # remove cache after finishing the simulation
    'cache_directory': '/urbansim_cache/psrc_zone', ### TODO: Set this cache_directory to something useful.
    'creating_baseyear_cache_configuration': cache_configuration['creating_baseyear_cache_configuration'],
    'input_configuration': DatabaseConfiguration(
        database_name = 'PSRC_2000_estimation_zone_pwaddell', #change
        ),                      
    'base_year':2000,
    'years':(2001, 2002),
    'seed':1,#(1,1),
    }