Skip to content

gralito/GQueryBuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

100 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GQueryBuilder v1.0.0

GQueryBuilder is a Python package that allows easy SQLite3 Queries building & executing.
This package helps developpers who do not master the SQLite syntax. GQueryBuilder transforms python objects into SQLite3 queries and can execute them.

Summary

  1. Presentation
  2. Getting started
  3. Features

1. Presentation

GQueryBuilder is my very first published Python package. It is designed for developpers who did not, and do no want to, learn the full SQLite syntax, when only a few operations are needed in their projects.

It's 'Python friendly' :
You create an object with the request parameters, it has a run() method and tadam !
You have your SQLite statement, readu to execute.

This package is only meant to be used with SQLite3 databases only (for the moment)

2. Getting started

A bit of context : You're working on your Python project and you need to send a request to a SQLite3 database.

Installation

Open a terminal window and run pip install GQueryBuiler

Create your Query

In this case, you just need to read data from the database.
Let's just create a EntryRead instance.

First, you need to import it :

from gquerybuilder.equery.entryread import EntryRead

and create an instance of the class (it requires a string argument : the path to your database)

my_request = EntryRead("path_to_database")

Now, let's give the differents 'arguments' to this request.
You need to read the 'name' field in the 'users' table.

my_request.select('name')
my_request.table(('users',))

A builder translates your query into SQLite language :

my_request.build_query()

=> your request is ready to be submitted

Just run it

my_data = my_request.run(receive=True)

3. Features

The parent class -> GQuery

Attributes
_query
database
Methods
_build_query()
run()

This is the parent class and should not be used directly.
It contains attributes and methods shared by children classes (that
means common SQLite elements to different kinds of requests.)

This class has 2 directs children classes :

  • TableQuery handles SQLite queries concerning tables management.
  • EntryQuery handles SQLite queries concerning the data management.

TableQuery

Attributes
_name
Methods
name()

1. TableCreate

Attributes
_name
_fields

Methods
add_field()
_build_fields()
build_query()

2. TableRemove

Attributes
if_exists

Methods
build_query()

3. TableUpdate

(coming soon)

EntryQuery

Attributes
_table
_where
Methods
table()
where()

EntryCreate

Attributes
_target
_values
Methods
target()
values()
build_query()

EntryRead

Attributes
_select
_options
Methods
select()
options()
_build_options()
build_query()

EntryRemove

Methods
build_query()

EntryUpdate

Attributes
_expressions
Methods
expressions()
build_query()

About

A simple package to create and execute SQLite queries

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages