[IBM]Databases and SQL for Data Science with Python - How to access DB using Python

2021. 5. 2. 14:32Data science/Database

반응형

Python

: ecosystem - NumPy, panda, matplotlib, SciPy

Ease of use, portable, support rdbms, DB-API, Detail document 

 

Notebook : Matlab, Jupyter, 

 

Jupyter Notebooks 

Language of choice, Share, Interactive Output, BIg Data integration

Application program call the DBMS, handle the error etc. 

 

Writing Code using DB-API

Benefits : Easy to implement and understand, encourages similarity between the Python modules used to access databases, achieves consistency, the portable, broad reach of database connectivity from Python

 

Concepts of the Python DB API 

- Connection Objects : database connections, manage transactions 

 * Connection Methods : .cursor() .commit(), .rollback(), .close()

- Cursor Objects: Database Queries, Scroll through the result set. Retrieve Results

* cursor Methods: .callproc(), execute(), executemany, getchone... 

 : behave like file name, to gain the access to DB 

 

Connecting to Database using ibm_db API

To close the connection: important to close the connection - we can avoid unused connections taking up resources

ibm_db.close(conn)

True 

 

반응형