Showing posts with label Python. Show all posts
Showing posts with label Python. Show all posts

Sunday, April 26, 2026

list of popular extensions for python developer - vscode extension

Python developers using Visual Studio Code, the following extensions are essential for improving productivity, code quality, and the overall development experience: 


Core Development & Language Support

Python by Microsoft: The foundational extension for Python development, providing core features like linting, debugging, code navigation, and environment switching.


Pylance: A high-performance language server that offers advanced IntelliSense, rapid type checking, and auto-imports.

Python Debugger: A dedicated extension for a seamless debugging experience, allowing you to set breakpoints and inspect variables directly in the editor. 



Code Formatting & Quality

Black Formatter: Automatically formats your code to adhere to the PEP 8 style guide on every save.


Flake8: A widely used linter that identifies syntax errors and styling issues as you type.


Ruff: A modern, extremely fast Python linter and formatter that can replace both Flake8 and Black.


autoDocstring: Quickly generates standardized docstrings (Google, NumPy, Sphinx) by typing triple quotes after a function definition. 



Productivity & UI Enhancements

Jupyter: Enables running Jupyter Notebooks within VS Code, ideal for data science and rapid prototyping.


Python Test Explorer: Provides a visual interface to manage and run tests using pytest or unittest frameworks.


Python Indent: Automatically determines the correct indentation level for each line, reducing common indentation errors.


Sort Lines: Helps organize long lists of imports or variables into alphabetical order with a simple command. 



AI & Collaboration

GitHub Copilot: An AI-powered tool that provides real-time code suggestions and entire function completions.


Visual Studio IntelliCode: Enhances autocomplete by using AI to predict and recommend the most likely code snippets based on your context.


Live Share: Allows multiple developers to collaborate on the same codebase in real-time, which is useful for pair programming. 



General Utility

Docker: Simplifies building, managing, and deploying containerized Python applications directly from the editor.


GitLens: Supercharges Git capabilities, providing detailed commit history and line-by-line blame annotations.


Code Spell Checker: Catches typos in variable names and comments, which is vital for maintaining a professional codebase. 

Friday, April 12, 2019

Check database status using python

Check database status using python


save this file as dbstatus.py




import cx_Oracle


db=cx_Oracle.connect("hr","hr","192.168.43.68/ind")

cursor=db.cursor()
cursor.execute(""" select name,open_mode from v$database """)

for count in cursor:
    print(count)










Output:

"C:\Program Files\Python37\python.exe" C:/Users/ANURAG/PycharmProjects/phython_master/conn.py
('IND', 'READ WRITE')

Process finished with exit code 0

Thursday, April 11, 2019

How can I access Oracle database from Python language using unique way ?


How can I access Oracle database from Python language?


we usually get issue while working with oracle database using python langaugae . The big issue how to connect with database .

There are many articles are available but when you run inti issue very few helps on out . 
if you are here then you issue is solved to how to connect with oracle database using python langaugae ?



* First you need to install python (in my case python version is  3.7.2)
* Install Oracle client (in my case oracle 18c)
* Update network configuration file tnanames.ora using db details 
* Stop firewall on linux (db install on linux in my case )
* Install oracle cx_Oracle  module in python using pip command as below 
* Start listener (db service) on oracle server
 

save the file as oracle_test.py

from __future__ import print_function

import cx_Oracle

# Connect as user "hr" with password "hr" to the "ind" service running on this server.
connection = cx_Oracle.connect("hr", "hr", "192.168.43.68/ind")

cursor = connection.cursor()
cursor.execute("""
    SELECT first_name, last_name
    FROM employees
    WHERE department_id = :did AND employee_id > :eid""",
    did = 55,
    eid = 180)
for fname, lname in cursor:
    print("Values:", fname, lname)


* you can upgrade pip module using below snapshot:

 

Wednesday, April 10, 2019

Oracle database network configuration files - listener.ora and tnsnames.ora


DB Network Configuration file 



tnsnames.ora

[oracle@pri admin]$ pwd
/u01/app/oracle/product/18.0.0/db/network/admin


[oracle@pri admin]$


[oracle@pri admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/18.0.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

IND =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.43.68)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = IND)
    )
  )

##LISTENER_IND =
##  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.43.68)(PORT = 1521))

USA =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.43.69)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = USA)
    )
  )


listener.ora


[oracle@pri admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/18.0.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.43.68)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = IND)
      (ORACLE_HOME = /u01/app/oracle/product/18.0.0/db)
      (SID_NAME = IND)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = USA)
      (ORACLE_HOME = /u01/app/oracle/product/18.0.0/db)
      (SID_NAME = USA)
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle




[oracle@pri admin]$


[oracle@pri ~]$ lsnrctl status

LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 10-APR-2019 22:46:01

Copyright (c) 1991, 2018, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.43.68)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date                10-APR-2019 17:03:30
Uptime                    0 days 5 hr. 42 min. 30 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/18.0.0/db/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/pri/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.43.68)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "IND" has 1 instance(s).
  Instance "IND", status UNKNOWN, has 1 handler(s) for this service...
Service "USA" has 1 instance(s).
  Instance "USA", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[oracle@pri ~]$

Oracle 18c client installation

Oracle 18c client installation 


*  Download oracle client software .
* unzip the software 

follow below steps for installation :-

setup run by administrator 




you can use different user as you requirement 












Add database details in tnanames.ora



C:\Users\ANURAG>
C:\Users\ANURAG>sqlplus hr/hr@ind

SQL*Plus: Release 18.0.0.0.0 - Production on Wed Apr 10 22:42:30 2019
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

Last Successful login time: Wed Apr 10 2019 20:48:43 +05:30

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.5.0.0.0

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
IND       READ WRITE


SQL>


ACE Associate

  ACE Associate