Skip to content

πŸš€ Learning about some patterns and using them to create a non-production-ready SQL builder

Notifications You must be signed in to change notification settings

kammradt/sql-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Welcome to SQL-builder πŸ’»

The logo

Description πŸ“

FAQ ❓

  1. Is this repo serious? No
  2. Should I use this? Only for learning purposes
  3. Is the code fast? No
  4. Will stuff like analytics functions be added? Of course no

I was studying the builder pattern and decided to apply in a "real problem".
This was a funny project to do, but please: Don't take it seriously

This project does not want in any way be a product, the-best-solution nor compete with any other similar project, this is just a the result of a learning process πŸš€

If you are searching for a real SQL builder using python, please check out at PyPika or Ibis

How to use ✏️

>>> from builder import Select

# Note that you can call explicitly .sql() or let __repr__ eval as str.
>>> Select('field').from_('table')
SELECT field FROM table;

>>> Select('field').from_('table').where_('field = 1')
SELECT field FROM table WHERE field = 1;

>>> Select('field0, field1').from_('table').where_('field0 = 0').or_('field1 = 1')
SELECT field0, field1 FROM table WHERE field0 = 0 OR field1 = 1;

>>> Select('field').from_('table').group_by_("field").order_by_("field")
SELECT field FROM table GROUP BY field ORDER BY field;

>>> Select().from_('table').limit_(10)
SELECT * FROM table LIMIT 10;

You can also verify all examples and test then at python examples.py.

Author

πŸ‘€ Vinicius Kammradt

About

πŸš€ Learning about some patterns and using them to create a non-production-ready SQL builder

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages