Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wisdomic Panda Wisdomic Panda

Hold the Vision, Trust the Process.

SQLAlchemy ORM guide for EOD Framework Class mapping for Celery-Batch Processing!

... basic example for SQLAlchemy Object Relational Mapper to associate user-defined Python classes with database tables.

Why ORM?

ORMs provide a high-level abstraction upon a relational database that allows a developer to write Python code instead of SQL to create, read, update and delete data and schemas in their database.

     # Oracle SQL
     SELECT * FROM USERS WHERE dept_code='DEVOPS';
     
     # Obtain everyone in the department code DEVOPS and assign to users variable.
     users = Users.objects.filter(zip_code=94107)

There are numerous ORM implementations written in Python, which includes:

  • SQLAlchemy
  • Peewee
  • The Django ORM
  • PonyORM
  • SQLObject

(Similarly, we have Hibernate, Eclipselink, Enterprise JavaBeans Entity Beans, Castor in java.)

🚧 Setting up local environment:

pip install sqlalchemy

    import sqlalchemy
    sqlalchemy.__version__
    1.2.7 

pip install flask

🚧 Run seed.sql for table creation in Database:

sqlite3 test_users.db < seed.sql

Verify
     #test_users.db will be created in your directory!
     
     sqlite3 test_users.db
     SQLite version 3.23.1 2018-04-10 17:39:29
     Enter ".help" for usage hints.
     
     sqlite> 

🚧 Get hands on: Kick-off

python -m DIRECTORY.Main.py

☕ Ingredients:

  • sqlalchemy
  • flask
  • sqlite3
  • Ubuntu 16.4 LTS

❗ I run on Mac OS/Ubuntu so you might have to slightly modify the code to make it work in your env.

📧 Drop In!! Seriously, it'd be great to discuss Technology.

About

Reference: SQLAlchemy ORM guide for EOD Framework Class mapping for Celery-Batch Processing!

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages