- Notifications
You must be signed in to change notification settings - Fork1
A simple SQL Query Builder Python module
License
co0lc0der/simple-query-builder-python
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is a small easy-to-use module for working with a database. It provides some public methods to compose SQL queries and manipulate data. Each SQL query is prepared and safe. QueryBuilder fetches data todictionary by default. At present time the component supports SQLite (file or memory).
Bug reports and/or pull requests are welcome
The module is available as open source under the terms of theMIT license
Install the current version withPyPI:
pip install simple-query-builder
Or from Github:
pip install https://github.com/co0lc0der/simple-query-builder-python/archive/main.zip
fromsimple_query_builderimport*qb=QueryBuilder(DataBase(),'my_db.db')# or DB in memoryqb=QueryBuilder(DataBase(),':memory:')
results=qb.select('users').all()
Result query
SELECT*FROM`users`;
results=qb.select('users').where([['id','>',1],'and', ['group_id','=',2]]).all()
Result query
SELECT*FROM`users`WHERE (`id`>1)AND (`group_id`=2);
qb.update('users', {'username':'John Doe','status':'new status' })\ .where([['id','=',7]])\ .limit()\ .go()
Result query
UPDATE`users`SET`username`='John Doe',`status`='new status'WHERE`id`=7LIMIT1;
More examples you can find indocumentation
I'm going to add the next features into future versions
- write more unit testes
- add subqueries for QueryBuilder
- add
BETWEEN
- add
WHERE EXISTS
- add TableBuilder class (for beginning
CREATE TABLE
, moveqb.drop()
andqb.truncate()
into it) - add MySQL support
- add PostgreSQL support
- add
WITH
- and probably something more
About
A simple SQL Query Builder Python module
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.