Showing posts with label example. Show all posts
Showing posts with label example. Show all posts

October 28, 2024

Understanding Python Dependency Versioning Symbols

Hi all,

It's been so confusing for me when the versions are with different operators.

Introduction: Managing dependencies in Python is crucial for ensuring your project runs smoothly across different environments. Dependencies, or libraries your project relies on, often need specific versions to maintain compatibility. This blog post will walk you through the symbols used in Python versioning and how they work to keep your project stable and functional.

What Are Python Dependencies?

In Python projects, dependencies are essential libraries that your project needs to function. They’re often listed in files like requirements.txt or Pipfile. To keep these dependencies compatible, Python uses specific symbols in versioning to define acceptable package versions. Let's dive into each symbol to see how they impact dependency management.

Key Python Versioning Symbols

  1. Exact Version (==)

    • Syntaxpackage_name==1.0.0
    • Meaning: Installs only the specified version. For example, numpy==1.18.5 installs version 1.18.5 of NumPy.
    • Best For: Strict requirements when a specific version is necessary for compatibility.
  2. Minimum Version (>=)

    • Syntaxpackage_name>=1.0.0
    • Meaning: Installs the specified version or newer. Example: Django>=3.1.0 installs any version of Django from 3.1.0 onward.
    • Best For: Ensuring updates without breaking compatibility with older versions.
  3. Maximum Version (<=)

    • Syntaxpackage_name<=1.0.0
    • Meaning: Installs only the specified version or older. For example, pandas<=1.2.3 won’t install any version beyond 1.2.3.
    • Best For: Avoiding potential incompatibilities with newer versions.
  4. Range of Versions (>= and <=)

    • Syntaxpackage_name>=1.0.0,<=2.0.0
    • Meaning: Installs a version within the specified range. Example: Flask>=1.1.0,<=2.0.1 includes versions between 1.1.0 and 2.0.1.
    • Best For: Ensuring some flexibility while staying within a compatible version range.
  5. Exclude Specific Versions (!=)

    • Syntaxpackage_name!=1.0.1
    • Meaning: Excludes a particular version. Example: requests!=2.21.0 installs any version of requests except 2.21.0.
    • Best For: Avoiding known buggy or incompatible versions.
  6. Compatible Release (~= or ^)

    • Syntaxpackage_name~=1.4 or package_name^1.4.0
    • Meaning: Installs versions up to, but not including, the next major version. Example: pandas~=1.2.3 includes versions like 1.2.4 but not 1.3.0.
    • Best For: Keeping compatibility within a minor version range.
  7. Pre-release and Development Versions (<>)

    • Syntaxpackage_name<2.0.0
    • Meaning: Allows installation of pre-release versions. Example: scipy<2.0.0 might include a development version like 1.5.0.dev.
    • Best For: Testing experimental versions, not typically used in production.

Example Usage in Requirements Files

Here are some example scenarios showing how to use these symbols:

  • Single Requirementflask==2.0.1 installs only version 2.0.1.
  • Multiple Requirementsrequests>=2.20.0,<3.0.0 installs versions from 2.20.0 up to, but not including, 3.0.0.
  • Combined Exclusionsscipy>=1.5.2,!=1.6.0,!=1.7.1 installs from 1.5.2 onwards but excludes 1.6.0 and 1.7.1.

Best Practices

  1. Avoid Exact Versioning (==) in Libraries: Using == restricts flexibility for future projects, so avoid it in libraries that might be used elsewhere.

  2. Use Compatible Release (~=) in Production: This symbol allows updates while maintaining compatibility.

  3. Test Development Versions Carefully: Isolate pre-release versions in a separate virtual environment for testing purposes.

  4. Regularly Update Dependencies: Keeping dependencies up to date helps with security and performance. Use pip commands to check for updates.

References

Conclusion

Understanding Python dependency versioning symbols can be the difference between a stable environment and one filled with compatibility issues. Following these guidelines will help you create reliable, well-maintained Python environments.

April 14, 2020

Microsoft SQL Server 2019 Express Docker image Example

Hi Folks,

Today I am going to explain the procedure for connecting to a Microsoft SQL Server 2019 Express edition docker image

Pre-requisites

  1. Docker Desktop
  2. Windows OS
  3. Powershell/command prompt

Procedure

Get and run docker image

> docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=<Your_Password>" -e "MSSQL_PID=Express" --name "<Your_SQL_Server_Name>" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest

Command information

Remove the "MSSQL_PID=Express" to run other version of SQL Server
Replace 2019 with required SQL Server version
Password should be atleast 8 characters with capital, small, numeric, special character combination
Use different port if you already have a local sql server
Name should not contain spaces

Check for docker container

> docker ps

You should able to see the container with your SQL Server name at the end in running status

Connect to SQL Server

docker exec -it "<Your_SQL_Server_Name>" /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "<Your_Password>"

You should be able to see "1>" prompt

Command information

Use the SQL Server name or user the container ID

Use database and play around with table(s)

Important
Multiple commands can be entered one after one, but to execute the set of command(s), you need give "GO" command.

Create Database

CREATE DATABASE SampleDB
GO

List all databases

SELECT Name from sys.Databases
GO

Start using the database

USE SampleDB
GO

Create table

CREATE TABLE UserInfo ( Id INT, Name VARCHAR(64))
GO

Insert values

INSERT INTO UserInfo (1, 'ABC')
GO

Retrieve table contents

SELECT * FROM UserInfo
GO

Exit from SQL Server

QUIT

Hope you are able to run the SQL Server Docker image.

Please send your feedback and comments to psrdotcom@gmail.com

November 26, 2018

Oracle Create User with custom tablespace and datafile

Hi all,

Through I have explained the procedure to delete/drop the user with tablespace and datafiles. I though of giving information about creating a user with custom tablespace and datafile.

Pre-requisites


  1. Oracle database
  2. Login as sys as sysdba

Procedure

Create tablespace

Syntax: CREATE TABLESPACE DATAFILE SIZE ;
Example: CREATE TABLESPACE sample_tablespace DATAFILE 'C:\\samplets.dbf' SIZE 100M;
Example: CREATE TABLESPACE sample_tablespace DATAFILE '\usr\local\datafiles\samplets.dbf' SIZE 100M;

User creation

Alter session
ALTER SESSION SET "_ORACLE_SCRIPT"=true;

Create User
Syntax: CREATE USER IDENTIFIED BY DEFAULT TABLESPACE ;
Example: CREATE USER sampleuser IDENTIFIED BY samplepwd DEFAULT TABLESPACE sample_tablespace;

Grant privilieges
Syntax: GRANT ALL PRIVILEGES to ;
Example: GRANT ALL PRIVILEGES to sampleuser;

Commit the commands
commit;

Now, you should be able to create the tablespace and made that as default tablespace for the newly created user.

Hope, this information helps you.

Please send your comments and feedback to psrdotcom@gmail.com

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com