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.
- Presentation
- Getting started
- Features
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)
A bit of context : You're working on your Python project and you need to send a request to a SQLite3 database.
Open a terminal window and run pip install GQueryBuiler
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
my_data = my_request.run(receive=True)
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 :
TableQueryhandles SQLite queries concerning tables management.EntryQueryhandles SQLite queries concerning the data management.
Attributes
_name
Methods
name()
Attributes
_name
_fields
Methods
add_field()
_build_fields()
build_query()
Attributes
if_exists
Methods
build_query()
(coming soon)
Attributes
_table
_where
Methods
table()
where()
Attributes
_target
_values
Methods
target()
values()
build_query()
Attributes
_select
_options
Methods
select()
options()
_build_options()
build_query()
Methods
build_query()
Attributes
_expressions
Methods
expressions()
build_query()