Introduction

sqlstring is a Python library for creating SQL query strings. sqlstring has four query string building classes: SelectBuilder, InsertBuilder UpdateBuilder, and DeleteBuilder.

Here is an an example of crating select query string using SelectBuilder:

from sqlstring.sql_builder import SelectBuilder

builder = SelectBuilder()
builder.from_table('address').where('state_code', '=', " 'CA' ")
builder.where('city', '=', " 'Oakland' ", 'AND')
query_string = builder.get_query_string()
# SELECT * FROM address WHERE state_code = 'CA' AND city = 'Oakland';

Installation

Install sqlstring from the Python Package Index using pip

$ pip install sqlstring

Credits

sqlstring uses