SQLAlchemy miniproject
The SQLAlchemy Object Relational Mapper presents a method of associating user-defined Python classes with database tables, and instances of those classes (objects) with rows in their corresponding tables.
The SQLAlchemy SQL Toolkit and Object Relational Mapper is a comprehensive set of tools for working with databases and Python. It has several distinct areas of functionality which can be used individually or combined together. Its major components are illustrated below, with component dependencies organized into layers:
[
Above, the two most significant front-facing portions of SQLAlchemy are the Object Relational Mapper and the SQL Expression Language. SQL Expressions can be used independently of the ORM. When using the ORM, the SQL Expression language remains part of the public facing API as it is used within object-relational configurations and queries.
pip install SQLAlchemy
from sqlalchemy import create_engine
db_engine = create_engine('sqlite:///sqlalchemy_example.db')
user=Table('users',metadata,
Column('ID',Integer,primary_key=True),
Column('name', String(40)),
Column('age', Integer)
)
import pandas as pd
col=['ID','Name','Age']
data=[(8,'Ironman',58),
(9,'Thor',300),
(10,'Hulk',55)]
df=pd.DataFrame(data,columns=col)