Posts

How to install pymongo? (Using Powershell in Windows) | Java Inspires

Image
How to install pymongo? (Using Powershell in Windows) Check for pymongo: $ pip list | Select-String "pymongo" To Install: $ pip install pymongo To check version: $ pip list | Select-String "pymongo" To Uninstall: $ pip uninstall pymongo Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https : //aka.ms/pscore6 PS C : \Users\developer> pip list | Select-String "pymongo" PS C : \Users\developer> PS C : \Users\developer> PS C : \Users\developer> pip install pymongo Collecting pymongo Using cached pymongo-3.12.1-cp310-cp310-win_amd64.whl (398 kB) Installing collected packages : pymongo Successfully installed pymongo-3.12.1 PS C : \Users\developer> PS C : \Users\developer> PS C : \Users\developer> PS C : \Users\developer> Successfully installed pymongo-3.12.1 Successfully : The term 'Successfully' is not recognized as the name of a cmdlet, function , sc...

How To Upgrade "PIP" in CMD Windows | Java Inspires

Image
How To Upgrade "PIP" in CMD Windows | Java Inspires ------------------------------------------------------------------------------ WARNING: You are using pip version 21.2.3; however, version 21.3.1 is available. You should consider upgrading via the 'C:\Users\developer\AppData\Local\Programs\Python\Python310\python.exe -m pip install --upgrade pip' command. ------------------------------------------------------------------------------ C:\Users\developer>python -m pip install --upgrade pip Requirement already satisfied: pip in c:\users\developer\appdata\local\programs\python\python310\lib\site-packages (21.2.3) Collecting pip   Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)      |████████████████████████████████| 1.7 MB 6.4 MB/s Installing collected packages: pip   Attempting uninstall: pip     Found existing installation: pip 21.2.3     Uninstalling pip-21.2.3:       Successfully uninstalled pip-21.2.3 Successfully inst...

How to download and install Docker Desktop in Windows | Java Inspires

Image
How to download and install Docker Desktop in Windows | Java Inspires In this video, we will see how to download and install docker desktop in windows desktop. download docker for windows WSL2 Linux kernel update package for x64 machines Docker Desktop for Windows user manual

Cannot connect to the MongoDB at localhost:27017

Image
Cannot connect to the MongoDB at localhost:27017. Error: Network is unreachable. Reason: couldn't connect to server localhost:27017, connection attempt failed: SocketException: Error connecting to localhost:27017 (127.0.0.1:27017) :: caused by :: No connection could be made because the target machine actively refused it. We get this error, if mongodb is unreachable means not running in our machine. In Windows: To start a MongoDB service that is in stop mode, please follow those steps. Press window key + R to open Run window. Then type "services.msc" to open services window. Then select MongoDB server, right click on it, finally click on the start menu entry.

[Java 8 Examples] - Transforming a List

In this post, we will see how to transform a list object into different list using streams from Java 8 and Method references. Example #1: Convert all names to Upper case names in a List package java8examples; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; /** * * @author #JavaInspires * */ public class Java8Example { public static void main(String[] args) { List<String> names = new ArrayList<String>(); names.add( "john" ); names.add( "Steve" ); names.add( "Lee" ); names.add( "Kent" ); names.add( "Robert" ); System.out.println(names); List<String> upperCaseNames = names.stream().map(String::toUpperCase).collect(Collectors.toList()); System.out.println(upperCaseNames); } } Output [john, Steve, Lee, Kent, Robert] [JOHN, STEVE, LEE, KENT, ROBERT]

[Java 8 Examples] How to remove all Null values from List using Java 8 Lamdas

 Hi Guys, Welcome to Java Inspires. In this post, we will see how to remove all Null values from a Java List using Java 8 Lamdas. package java8examples; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * * @author #JavaInspires * */ public class Java8Example { public static void main(String[] args) { // create a string list List<String> names = new ArrayList<String>(); // add elements names.add( null ); names.add( "John" ); names.add( null ); names.add( "David" ); names.add( null ); // print names list with null values System.out.println(names); // remove null values names.removeIf(Objects::isNull); System.out.println(names); } } Output [ null , John, null , David, null ] [John, David] About Objects class: public final class Objects extends Object This class consists of static utility methods for operating on objects. These utilities include null-safe or...

Python MongoDB - pymongo Tutorial

How to install pymongo using pip? python -m pip install pymongo How to check pymongo version using pip ? pip list | grep pymongo How top check pymongo version from code? import pymongo print( "pymongo version :" ,pymongo.__version__) pymongo version : 3.12.0 How to create connection with MondoDB using pymongo? import pymongo # connection to mongodb mc=pymongo.MongoClient( "localhost" ,27017) print( "Connected to mongo ..." ,mc) Connected to mongo ... MongoClient(host=[ 'localhost:27017' ], document_class=dict, tz_aware= False , connect= True ) How to create new database in MongoDB in Python? import pymongo # connection to mongodb mc=pymongo.MongoClient( "localhost" ,27017) # create new database new_db = mc[ "new_db" ] How to get list of database names using pymongo? import pymongo # connection to mongodb mc=pymongo.MongoClient( "localhost" ,27017) db_list = mc.list_database_names() for db in ...