Skip to content

Commit 5657be2

Browse files
committed
v0.2.0.3
- Issue #46 fixed - LIKE (and all other pql const-s) added to sqllex.constants.sqlite - WHERE type checking fixed - docs update
1 parent 9ea295a commit 5657be2

12 files changed

Lines changed: 183 additions & 68 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ dmypy.json
115115
# Pyre type checker
116116
.pyre/
117117

118-
# Database type checker
118+
# Databases (tests and other)
119119
*.db
120+
*.db-shm
121+
*.db-wal
120122

121123
# Statistic
122124
*.prof

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<img src="./pics/sqllex-logo.svg" width="300px" alt="sqllex logo">
55

6-
# SQLLEX v0.2.0.2 🥳📚
6+
# SQLLEX v0.2.0.3 🥳📚
77

88
![python-3-9]
99
[![lgtm-quality-img]][lgtm-quality-src]
@@ -27,7 +27,7 @@ pip install sqllex
2727

2828
| Version | Status | Tests, and actions |
2929
| :--------: | :----------------------------: | :---: |
30-
| `0.2.0.2` | ✔️ supported <br> ✔️ stable | [![code-ql-img]][code-ql-src] <br> [![sqlite3x-test-img]][sqlite3x-test-src] <br> [![pypi-upload-img]][pypi-upload-img] |
30+
| `0.2.0.3` | ✔️ supported <br> ✔️ stable | [![code-ql-img]][code-ql-src] <br> [![sqlite3x-test-img]][sqlite3x-test-src] <br> [![pypi-upload-img]][pypi-upload-img] |
3131
| `0.1.10.5` | ⚠️ outdated <br> | ⚠️ Mostly passing |
3232
| `<=0.1.10.4` | ❌️ outdated ||
3333

docs/README.md

Lines changed: 127 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Here you can find some explanations and examples for Sqllex ORM <br>
1313
- [PostgreSQLx](about-postgresqlx.md)
1414
- [PostgreSQLxTable](about-table.md)
1515
- [AbstractColumn](about-column.md)
16-
- [SearchCondition](searchcondition-about.md)
16+
- [SearchCondition](about-searchcondition.md)
1717
- [Project Showcase](sqllex-showcase.md)
1818

1919
---
@@ -25,38 +25,146 @@ Here you can find some explanations and examples for Sqllex ORM <br>
2525
Sqllex is a python ORM library for comfortable and safe interaction with databases.
2626

2727
If you've ever worked with databases using python, you know what does "Eat nails while writing SQL-scripts" means.
28-
So give a sqllex deal with it, just call needed method, give it a data or necessary parameters and it's done.
29-
There no `con.cursor()`, only human `db.insert()`, `db.select()`, `db['my_table']`,
30-
only beautiful and pythonic code without unnecessary SQL-witchcrafting.
31-
32-
Sqllex is not like other ORM's, has unfriendly API and awesome for beginners (and not only).
33-
By the reason it is just an add-on for sqlite3, there will be easy to find explains for typical sqlite3 raised errors.
34-
And any moment you could call `db.execute()` method and run any sql-script directly in sqlite3.
28+
So give a sqllex deal with it, just call needed method, give it a data or necessary parameters and done.
3529

36-
It'll be a lot easier to show then explain. So down below is a few examples.
30+
THERE NO `con.cursor()`, only human `db.insert()`, `db.select()`, `db['table']`,
31+
only beautiful and pythonic code without unnecessary SQL-witchcrafting.
3732

38-
### If you never used SQLite before read [this awesome example #0](sqlite3x-aex-0.md)
33+
Sqllex has friendly API, documentation and it's awesome for beginners (but not only).
34+
By the reason it is just an add-on for sqlite3/psycopg2, there will be easy to find explains for typical sqlite3 raised errors.
35+
And also in any moment you can call `db.execute()` method and run any sql-script directly in the database.
3936

40-
### Otherwise, you can check out [this one example #1](sqlite3x-aex-1.md)
37+
It'll be a lot easier to show then explain. So check out examples down below.
4138

42-
### [Project showcase](sqllex-showcase.md)
39+
---
4340

44-
# Pages
41+
## Pages
4542

4643
- ### [SQLite3x](about-sqlite3x.md)
4744
- [SQLite3xTable](about-table.md)
48-
- Examples
49-
- [Awesome example #0](sqlite3x-aex-0.md)
50-
- [Awesome example #1](sqlite3x-aex-1.md)
45+
- **Examples**
46+
- [Awesome example #0](examples/sqlite3x-aex-0.md)
47+
- [Awesome example #1](examples/sqlite3x-aex-1.md)
5148

5249
- ### [PostgreSQLx](about-postgresqlx.md)
5350
- [PostgreSQLxTable](about-table.md)
5451

5552
- ### [AbstractColumn](about-column.md)
5653

57-
- ### [SearchCondition](searchcondition-about.md)
54+
- ### [SearchCondition](about-searchcondition.md)
5855

5956
- ### [Project Showcase](sqllex-showcase.md)
60-
- [Vaccine Update System](sqllex-showcase.md#vaccine-update-systemhttpsdeepnotecomabidvaccine-update-dashboard-gybicp-ftaydgmjimofj0w--by-kingabzpro)
61-
- [Sqllex for Data Science Using Pandas](sqllex-showcase.md#sqllex-for-data-science-using-pandashttpsdeepnotecomabidsqllex-simple-and-faster-7wxrco0hrxaqvaixo8qjbq-by-kingabpro)
57+
- [Vaccine Update System](sqllex-showcase.md#vaccine-update-systemcase-vsu-src-by-kingabzprokingabzpro)
58+
- [Sqllex for Data Science Using Pandas](sqllex-showcase.md#sqllex-for-data-science-using-pandascase-dsup-src-by-kingabzprokingabzpro)
6259
- [Add your own project at this list](https://github.com/v1a0/sqllex/edit/main/docs/sqllex-showcase.md)
60+
61+
62+
---
63+
64+
## How does this work?
65+
66+
Basic idea of sqllex as any ORM is to give user an interface to interact with a database as abstract object.
67+
68+
```markdown
69+
┌───────────────────────────────────────────┐
70+
│ DATABASE │
71+
│ ┌───────────────────────────────────┐ │
72+
│ │ TABLE │ │
73+
│ │ ┌───────────────────────────┐ │ │
74+
│ │ │ COLUMN │ │ │
75+
│ │ │ ┌───────────────────┐ │ │ │
76+
│ │ │ │ DATA │ │ │ │
77+
│ │ │ └───────────────────┘ │ │ │
78+
│ │ └───────────────────────────┘ │ │
79+
│ │ │ │
80+
│ └───────────────────────────────────┘ │
81+
└───────────────────────────────────────────┘
82+
```
83+
84+
Imagine you have a database called `'server.db'` with only one table inside named `'users'`,
85+
this table has 3 columns `'id'`, `'name'` and `'age'` (so as a pic down below)
86+
87+
88+
```markdown
89+
┌───────────────────────────────────────────┐
90+
│ DATABASE 'server.db' │
91+
│ ┌───────────────────────────────────┐ │
92+
│ │ TABLE 'users' │ │
93+
│ │ ┌───────────────────────────┐ │ │
94+
│ │ │ COLUMN 'id' │ │ │
95+
│ │ │ ┌───────────────────┐ │ │ │
96+
│ │ │ │ INTEGER DATA │ │ │ │
97+
│ │ │ └───────────────────┘ │ │ │
98+
│ │ └───────────────────────────┘ │ │
99+
│ │ ┌───────────────────────────┐ │ │
100+
│ │ │ COLUMN 'name' │ │ │
101+
│ │ │ ┌───────────────────┐ │ │ │
102+
│ │ │ │ TEXT DATA │ │ │ │
103+
│ │ │ └───────────────────┘ │ │ │
104+
│ │ └───────────────────────────┘ │ │
105+
│ │ ┌───────────────────────────┐ │ │
106+
│ │ │ COLUMN 'age' │ │ │
107+
│ │ │ ┌───────────────────┐ │ │ │
108+
│ │ │ │ INTEGER DATA │ │ │ │
109+
│ │ │ └───────────────────┘ │ │ │
110+
│ │ └───────────────────────────┘ │ │
111+
│ └───────────────────────────────────┘ │
112+
└───────────────────────────────────────────┘
113+
```
114+
115+
With the sqllex you can interact with this database in the craziest way
116+
117+
```python
118+
# Import necessary modules
119+
from sqllex.classes import SQLite3x
120+
from sqllex.constants.sqlite import *
121+
122+
# Database
123+
db = SQLite3x('server.db')
124+
125+
# Create this table
126+
db.create_table(
127+
'users',
128+
{
129+
'id': INTEGER,
130+
'name': TEXT,
131+
'age': INTEGER
132+
},
133+
IF_NOT_EXIST=True
134+
)
135+
136+
table_users = db['users']
137+
# table_users = db.get_table('users') <-- the same
138+
139+
# add one user
140+
table_users.insert(1, 'Sqllex', 33)
141+
142+
# add 3 more
143+
table_users.insertmany(
144+
(2, 'Phizilion', 22),
145+
(3, 'kingabzpro', 44),
146+
(4, 'asadafasab', 55)
147+
)
148+
149+
print(table_users.select_all()) # [(1, 'Sqllex', 33), (2, 'Phizilion', 22), (3, 'kingabzpro', 44), (4, 'asadafasab', 55)]
150+
151+
# Get column age as object
152+
column_age = table_users['age']
153+
154+
print(
155+
table_users.select(
156+
WHERE=(column_age > 40)
157+
)
158+
) # [(3, 'kingabzpro', 44), (4, 'asadafasab', 55)]
159+
160+
161+
column_name = table_users['name']
162+
163+
164+
print(
165+
table_users.select(
166+
WHERE=(column_age > 40) & (column_name |LIKE| 'kin%')
167+
)
168+
) # [(3, 'kingabzpro', 44)]
169+
170+
```

docs/about-postgresqlx.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ db = PostgreSQLx(
6767
- [user *](postgresqlx-properties.md#postgresqlxuser)
6868

6969

70+
```
7071
* - available only for this specific database-class
72+
```
7173

7274
### [Back to home](README.md)
File renamed without changes.

docs/about-sqlite3x.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ db = SQLite3x(
6262
- [tables_names](database-properties.md#abstractdatabasetables_names)
6363

6464

65+
```
6566
* - available only for this specific database-class
67+
```
6668

6769
### [Back to home](README.md)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,4 @@ Run it and we got:
297297

298298
### Explore more and learn how awesome SQL and SQLLEX is!
299299

300-
### [Back to home](README.md)
300+
### [Back to home](../README.md)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Imagine you need create some database, with structure like:
4141
</table>
4242

4343

44-
[I don't need explains, just show me the code](#Code)
44+
[I don't need explains, just show me the code](#code)
4545

4646

4747
```python
@@ -207,7 +207,7 @@ db.disconnect() # unlock your database and save all changes
207207
<details>
208208
<summary id="just_code_1">Code without comments</summary>
209209

210-
210+
### Code
211211

212212
```python
213213
# from sqllex import *
@@ -295,4 +295,4 @@ db.disconnect()
295295

296296
### Congratulation, now you know basic SQLite3x methods! Explore more features and method on the links down below.
297297

298-
### [Back to home](README.md)
298+
### [Back to home](../README.md)

sqllex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"\033[0m"
1818
"\n")
1919

20-
__version__ = '0.2.0.2'
20+
__version__ = '0.2.0.3'
2121

2222
__all__ = [
2323
# classes

sqllex/constants/postgresql.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
INET: str = "INET"
2424
INT: str = "INT"
2525
INT4: str = "INT4"
26-
INTEGER: ColumnDataType = INTEGER
26+
# INTEGER: ColumnDataType = INTEGER
2727
# INTERVAL: str =
2828
JSON: str = "JSON"
2929
JSONB: str = "JSONB"
@@ -38,14 +38,14 @@
3838
POINT: str = "POINT"
3939
POLYGON: str = "POLYGON"
4040
FLOAT4: str = "FLOAT4"
41-
REAL: ColumnDataType = REAL
41+
# REAL: ColumnDataType = REAL
4242
INT2: str = "INT2"
4343
SMALLINT = INT2
4444
SERIAL2: str = "SERIAL2"
4545
SMALLSERIAL = SERIAL2
4646
SERIAL4: str = "SERIAL4"
4747
SERIAL = SERIAL4
48-
TEXT: ColumnDataType = TEXT
48+
# TEXT: ColumnDataType = TEXT
4949
# TIME: str =
5050
# TIME: str =
5151
# TIMESTAMP: str =

0 commit comments

Comments
 (0)