Giter VIP home page Giter VIP logo

dblite's Introduction

dblite

GitHub issues GitHub forks GitHub stars GitHub license PyPI - Python Version

Python wrapper for sqlite3 & aiosql

Table of Contents

Installation

To install dblite, simply:

$ python3 -m pip install -U git+https://github.com/anbuhckr/dblite.git

Getting Started

#! /usr/bin/env python3

import asyncio
from dblite import dbLite, aioDbLite

def main():
    db = dbLite('db1.db')
    db.create('users', id='int', name='text', age='int', pos='text')
    print(db.data('users'))
    db.add('users', id=1, name='Jhon', age=32, pos='Developer')
    db.add('users', id=2, name='Doe', age=30, pos='Manager')
    db.add('users', id=3, name='Rio', age=29, pos='Marketing')
    print(db.data('users'))
    db.remove('users', id=3)
    print(db.data('users'))
    db.update('users', age=31, pos='CEO', id=1)
    print(db.data('users'))
    print(db.select('users', '*', id=1))
    db.close()

async def amain():
    aiodb = await aioDbLite('db2.db')
    await aiodb.create('users', id='int', name='text', age='int', pos='text')
    print(await aiodb.data('users'))
    await aiodb.add('users', id=1, name='Jhon', age=32, pos='Developer')
    await aiodb.add('users', id=2, name='Doe', age=30, pos='Manager')
    await aiodb.add('users', id=3, name='Rio', age=29, pos='Marketing')
    print(await aiodb.data('users'))
    await aiodb.remove('users', id=3)
    print(await aiodb.data('users'))
    await aiodb.update('users', age=31, pos='CEO', id=1)
    print(await aiodb.data('users'))
    print(await aiodb.select('users', '*', id=1))
    await aiodb.close()

main()
asyncio.run(amain())

Result:

# sync
# create table
[]
# add data
[(1, 'Jhon', 32, 'Developer'), (2, 'Doe', 30, 'Manager'), (3, 'Rio', 29, 'Marketing')]
# remove Rio
[(1, 'Jhon', 32, 'Developer'), (2, 'Doe', 30, 'Manager')]
# update Jhone age
[(1, 'Jhon', 31, 'CEO'), (2, 'Doe', 30, 'Manager')]
# show user with id 1
[(1, 'Jhon', 31, 'CEO')]


# async
# create table
[]
# add data
[(1, 'Jhon', 32, 'Developer'), (2, 'Doe', 30, 'Manager'), (3, 'Rio', 29, 'Marketing')]
# remove Rio
[(1, 'Jhon', 32, 'Developer'), (2, 'Doe', 30, 'Manager')]
# update Jhone age
[(1, 'Jhon', 31, 'CEO'), (2, 'Doe', 30, 'Manager')]
# show user with id 1
[(1, 'Jhon', 31, 'CEO')]

dblite's People

Contributors

anbuhckr avatar vasia123 avatar

Stargazers

Justi avatar  avatar bagus ardi @bistondroid avatar  avatar supergasken avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

vasia123

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.