Skip to content

SQLBatis is a tool that provides an easier way to interact with the DB with a lower learning curve.

License

Notifications You must be signed in to change notification settings

1011-1-000/SQLBatis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQLBatis

License PyPI - Python Version Build Status DOC

Under Documentation

SQLBatis is a tool that inspired by the Mybatis, it provides an easier way to interact with the database through the raw sql.

SQLBatis allows you to migrate, update your database according to the data model you defined in your app.Also, there are several decorators and builtin functions which give you capbility to interact with your database.

Let's try it.

Requirements

Installation

Install SQLBatis with command pip::

pip install sqlbatis

Quick Tutorial

Connect to the DB

from sqlbatis import SQLBatis
db = SQLBatis('sqlite:///:memory:')

We have provided the decorator @db.query to execute the raw sql, Here are CRUD examples:

from sqlalchemy import Column, Integer, String
from sqlbatis import SQLBatis, Model
db = SQLBatis('sqlite:///:memory:')

class User(Model):

    id = Column(Integer, primary_key=True)
    name = Column(String)
    full_name = Column(String)


@db.query('INSERT INTO user (name, full_name) VALUS(:name, :full_name)')
def create(name, full_name):
    pass

@db.query('SELECT * FROM user')
def query_user():
    pass

@db.query('UPDATE user SET name = :name WHERE id = :id')
def update_user(name, id):
    pass

@db.query('DELETE FROM user WHERE id = :id')
def delete_user(id):
    pass

if __name__ == '__main__':
    create('10111000', 'Leo')

Documentation

More details please refer to the docs

About

SQLBatis is a tool that provides an easier way to interact with the DB with a lower learning curve.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published