Create a new Impala database

        Parameters
        ----------
        name : string
          Database name
        path : string, default None
          HDFS path where to store the database data; otherwise uses Impala
          default
6312
def create_database(self, name, path=None, force=False):
        
        if path:
            # explicit mkdir ensures the user own the dir rather than impala,
            # which is easier for manual cleanup, if necessary
            self.hdfs.mkdir(path)
        statement = ddl.CreateDatabase(name, path=path, can_exist=force)
        return self._execute(statement)
584977
def init_db(self):
    '''
    '''
    self.session = None

    if not os.path.exists(self.data_base):
        mkdir_p(self.data_base)

    self.database = "%s/%s" %(self.data_base, self.study_id)
    if not os.path.exists(self.database):
        mkdir_p(self.database)
499440
def _get_db(self):
        
        if self._connection:
            try:
                self._connection.close()
            except Exception:
                pass

        return DB(storageFromFile(open(self.conf_path)))
1302372
def create_backup(self, instance, name, description=None):
        
        return instance.create_backup(name, description=description)
354563
def database(name, database_id = nil, &block)
      @databases << get_class_from_scope(Database, name)
        .new(self, database_id, &block)
    end
439414
def db_create(name,
              user=None,
              host=None,
              port=None,
              maintenance_db=None,
              password=None,
              tablespace=None,
              encoding=None,
              lc_collate=None,
              lc_ctype=None,
              owner=None,
              template=None,
              runas=None):
    '''
    

    '''

    # Base query to create a database
    query = 'CREATE DATABASE "{0}"'.format(name)

    # "With"-options to create a database
    with_args = salt.utils.odict.OrderedDict([
        ('TABLESPACE', _quote_ddl_value(tablespace, '"')),
        # owner needs to be enclosed in double quotes so postgres
        # doesn't get thrown by dashes in the name
        ('OWNER', _quote_ddl_value(owner, '"')),
        ('TEMPLATE', template),
        ('ENCODING', _quote_ddl_value(encoding)),
        ('LC_COLLATE', _quote_ddl_value(lc_collate)),
        ('LC_CTYPE', _quote_ddl_value(lc_ctype)),
    ])
    with_chunks = []
    for key, value in with_args.items():
        if value is not None:
            with_chunks += [key, '=', value]
    # Build a final query
    if with_chunks:
        with_chunks.insert(0, ' WITH')
        query += ' '.join(with_chunks)

    # Execute the command
    ret = _psql_prepare_and_run(['-c', query],
                                user=user, host=host, port=port,
                                maintenance_db=maintenance_db,
                                password=password, runas=runas)
    return ret['retcode'] == 0
164013
def create_database(self, name, owner=None):
        
        statement = ddl.CreateDatabase(name, owner=owner)
        self._execute(statement)
551251
def create(self, datastore_id=None):
        """"""

        datastore = self._get_ogrdatastore_by_id(datastore_id)
        if not datastore:
            abort(404)

        # only "directory" datastores are supported at this point
        if datastore.connection_type != 'directory':
            abort(400)

        # use mkstemp to store the file to avoid issues with
        # NamedTemporaryFile that can't be open a second time
        # on Windows. See:
        # http://docs.python.org/library/tempfile.html#tempfile.NamedTemporaryFile
        # "Whether the name can be used to open the file a second time, while the
        # named temporary file is still open, varies across platforms (it can be so
        # used on Unix; it cannot on Windows NT or later).
        fd, fn = mkstemp()
        tmpfile = os.fdopen(fd, 'wb')
        fieldstorage = request.POST['datasources']
        shutil.copyfileobj(fieldstorage.file, tmpfile)
        fieldstorage.file.close()
        tmpfile.close()

        extractall(fn,
                   request.POST['datasources'].filename,
                   datastore.datastore_str)

        # we are reponsible for removing the temporary file
        os.remove(fn)

        response.status = 201
1146816
def db_use_local_file(self, arg, filename=None):
        '''  '''
        # interactive = False  # Never used
        if filename is None:
            # interactive = True  # Never used
            filename = raw_input('Enter the filename of the local SQLLite '
                                 'database you would like to use '
                                 '[default=participants.db]: ')
            if filename == '':
                filename = 'participants.db'
        base_url = "sqlite:///" + filename
        self.config.set("Database Parameters", "database_url", base_url)
        print "Updated database setting (database_url): \n\t", \
        self.config.get("Database Parameters", "database_url")
        if self.server.is_server_running() == 'yes':
            self.server_restart()
942669
def create_db_in_shard(db_name, shard, client=None):
    
    client = client or pymongo.MongoClient()
    # flush the router config to ensure it's not stale
    res = client.admin.command('flushRouterConfig')
    if not res.get('ok'):
        raise RuntimeError("unable to flush router config")
    if shard not in get_ids(client.config.shards):
        raise ValueError(f"Unknown shard {shard}")
    if db_name in get_ids(client.config.databases):
        raise ValueError("database already exists")
    # MongoDB doesn't have a 'create database' command, so insert an
    #  item into a collection and then drop the collection.
    client[db_name].foo.insert({'foo': 1})
    client[db_name].foo.drop()
    if client[db_name].collection_names():
        raise ValueError("database has collections")
    primary = client['config'].databases.find_one(db_name)['primary']
    if primary != shard:
        res = client.admin.command(
            'movePrimary', value=db_name, to=shard)
        if not res.get('ok'):
            raise RuntimeError(str(res))
    return (
        f"Successfully created {db_name} in {shard} via {client.nodes} "
        f"from {hostname}")
376595
@Override
	public void createDb(String dbName) {
		String dbPath = getDbPath(dbName);
		if (map.containsKey(dbPath)) {
			throw DBLogger.newUser("Database already exists: " + dbPath);
		}
		map.put(dbPath, new ArrayList<ByteBuffer>());
		
		//create files

		//DB file
		FreeSpaceManager fsm = new FreeSpaceManager();
		StorageRootInMemory root = 
				new StorageRootInMemory(dbPath, "rw", ZooConfig.getFilePageSize(), fsm);
		IOResourceProvider file = root.createChannel();
		StorageChannelOutput out = file.createWriter(false);
		fsm.initBackingIndexNew(file);

		int headerPage = out.allocateAndSeek(PAGE_TYPE.DB_HEADER, 0);
		if (headerPage != 0) {
			throw DBLogger.newFatalInternal("Header page = " + headerPage);
		}
		int rootPage1 = out.allocateAndSeek(PAGE_TYPE.ROOT_PAGE, 0);
		int rootPage2 = out.allocateAndSeek(PAGE_TYPE.ROOT_PAGE, 0);

		//header: this is written further down

		//write User data
		int userData = out.allocateAndSeek(PAGE_TYPE.USERS, 0);

		//dir for schemata
		int schemaData = out.allocateAndSeekAP(PAGE_TYPE.SCHEMA_INDEX, 0, -1);
		//ID of next page
		out.writeInt(0);
		//Schema ID / schema data (page or actual data?)
		//0 for no more schemata
		out.writeInt(0);


		//dir for indices
		int indexDirPage = out.allocateAndSeek(PAGE_TYPE.INDEX_CATALOG, 0);
		//ID of next page
		out.writeInt(0);
		//Schema ID / attribute ID / index type / Page ID
		//0 for nor more indices
		out.writeInt(0);

		//OID index
		PagedOidIndex oidIndex = new PagedOidIndex(file);
		int oidPage = file.writeIndex(oidIndex::write);

		//Free space index
		int freeSpacePg = file.writeIndex(fsm::write);
		
		//write header
		out.seekPageForWrite(PAGE_TYPE.DB_HEADER, headerPage);
		out.writeInt(DiskIO.DB_FILE_TYPE_ID);
		out.writeInt(DiskIO.DB_FILE_VERSION_MAJ);
		out.writeInt(DiskIO.DB_FILE_VERSION_MIN);
		out.writeInt(ZooConfig.getFilePageSize());
		out.writeInt(rootPage1);
		out.writeInt(rootPage2);

		writeRoot(out, rootPage1, 1, userData, oidPage, schemaData, indexDirPage, freeSpacePg, 
				fsm.getPageCount());
		writeRoot(out, rootPage2, 0, userData, oidPage, schemaData, indexDirPage, freeSpacePg, 
				fsm.getPageCount());

		file.close();
		file = null;
		root.close();
		root = null;
		out = null;


		//initial schemata
		Properties props = new ZooJdoProperties(dbName);
		PersistenceManagerFactory pmf = 
			JDOHelper.getPersistenceManagerFactory(props);
		PersistenceManager pm = pmf.getPersistenceManager();
		pm.currentTransaction().begin();

		ZooSchema schema = ZooJdoHelper.schema(pm);
		schema.addClass(PersistenceCapableImpl.class);
		schema.addClass(DBHashMap.class);
		schema.addClass(DBArrayList.class);

		pm.currentTransaction().commit();
		pm.close();
		pmf.close();
	}
1193262
def newFile(self, *path):
        
        assert len(path) > 0, "newFile requires a nonzero number of segments"
        if self.dbdir is None:
            if self.filesdir is None:
                raise RuntimeError("This in-memory store has no file directory")
            else:
                tmpbase = self.filesdir
        else:
            tmpbase = self.dbdir
        tmpname = tmpbase.child('temp').child(str(tempCounter.next()) + ".tmp")
        return AtomicFile(tmpname.path, self.newFilePath(*path))
976653
def create_database(self, database):
        
        url = "db"

        data = {'name': database}

        self.request(
            url=url,
            method='POST',
            data=data,
            expected_response_code=201
        )

        return True
801001
private static Path pathForMetadata(Path root, String namespace, String name) {
    return new Path(
        FileSystemDatasetRepository.pathForDataset(root, namespace, name),
        METADATA_DIRECTORY);
  }
377472
def create(self, name):
        """"""
        if not os.path.exists(self.directory):
            os.makedirs(self.directory)

        filename = self.get_new_filename(name)
        with open(os.path.join(self.directory, filename), 'w') as fp:
            fp.write("def up(db): pass\n\n\n")
            fp.write("def down(db): pass\n")
            logger.info(filename)
161892
def create_db(name, **client_args):
    '''
    
    '''
    if db_exists(name, **client_args):
        log.info('DB \'%s\' already exists', name)
        return False

    client = _client(**client_args)
    client.create_database(name)

    return True
1091200
def _create_database(self):
        

        self._logger.info('creating user database')
        sql = '''CREATE TABLE IF NOT EXISTS user (
            username NOT NULL PRIMARY KEY,
            pwd_salt NOT NULL,
            pwd_hash NOT NULL,
            full_name,
            trusted NOT NULL DEFAULT 0,
            readonly NOT NULL DEFAULT 0
        )'''
        self._db_curs.execute(sql)
        self._db_conn.commit()