Skip to main content

A SQL ORM Tool

Project description

Golla

  • A SQL Query free ORM
  • Support SQLAlchemy ORM

Create Connection

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

host = 'localhost'
user = 'postgres'
password = 'root'
data_base = 'postgres'
port = '5432'
URL = 'postgresql://{}:{}@{}:{}/{}'
URL = URL.format(user, password, host, port, data_base)
ds_schema = 'public'

engine = create_engine(URL, encoding='utf8')
engine.connect()
Connection = sessionmaker(bind=engine)()

Create Model class

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Integer, String, Column

from golla.table import BaseChild

Base = declarative_base()

BaseChild.Connection = Connection


class Employee(Base, BaseChild):
    __tablename__ = "employee"
    EMPID = Column("emp_id", Integer, primary_key=True)
    NAME = Column("NAME", String)
    Age = Column("Age", Integer)

Save object into DB

e = Employee()
e.EMPID = 203
e.Age = 20
e.NAME = "b"

Employee.save(e)

Get records from table by id

emp = Employee().get_by_id(EMPID=100)

Get all records

emps = Employee().get_all()

Delete records from table by id

Employee().delete_by_id(EMPID=201)

MIT License : Copyright (c) 2019 Abhimanyu Haralukallu

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Golla-0.0.0.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

Golla-0.0.0-py3-none-any.whl (2.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page