Path: blob/master/Key Python Libraries/Key Python Libraries - Day 2.ipynb
3074 views
Data Visualization
Bokeh
Interactive charts visualization.
Bokeh renders its plots using HTML and JavaScript
Uses modern web browsers for presenting elegant, concise construction of novel graphics with high-level interactivity.
Plotly
Plotly has hover tool capabilities that allow us to detect any outliers or anomalies in numerous data points.
It allows more customization.
It makes the graph visually more attractive
Connecting to Database using Python
The Python standard for database interfaces is the Python DB-API.In most of the cases one have download a separate DB API module for each database access.
The DB API provides a minimal standard for working with databases using Python structures and syntax wherever possible. This API includes the following −
Importing the API module.
Acquiring a connection with the database.
Issuing SQL statements and stored procedures.
Closing the connection
1. Database Connection: SQlite3
What is SQLite?
SQLite is a relational database management system (In C) ,that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine.
SQLite3 can be integrated with Python using sqlite3 module
No need to install as it shipped by default along with Python version 2.5.x onwards.
To use sqlite3 module, you must first create a connection object that represents the database and then optionally you can create a cursor object, which will help you in executing all the SQL statements.
conda install -c blaze sqlite3
Important APIs
sqlite3.connect(database [,timeout ,other optional arguments])
This API opens a connection to the SQLite database file. You can use ":memory:" to open a database connection to a database that resides in RAM instead of on disk. If database is opened successfully, it returns a connection object.
connection.cursor([cursorClass])
This routine creates a cursor which will be used throughout of your database programming with Python. This method accepts a single optional parameter cursorClass.
cursor.execute(sql [, optional parameters])
This routine executes an SQL statement. The SQL statement may be parameterized (i. e. placeholders instead of SQL literals). The sqlite3 module supports two kinds of placeholders: question marks and named placeholders (named style).
For example − cursor.execute("insert into name values (?, ?)", (who, income))
connection.commit()
This method commits the current transaction. If you don't call this method, anything you did since the last call to commit() is not visible from other database connections.
connection.rollback()
This method rolls back any changes to the database since the last call to commit().
SQLAlchemy is basically referred to as the toolkit of Python SQL that provides developers with the flexibility of using the SQL database.
The benefit of using this particular library is to allow Python developers to work with the language’s own objects, and not write separate SQL queries
They can basically use Python to access and work with databases
SQLAlchemy is also an Object Relational Mapper which is a technique used to convert data between databases or OOP languages such as Python