postgresdb3 0.2.0__tar.gz → 0.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: postgresdb3
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Python uchun oddiy PostgreSQL wrapper
5
5
  Home-page: https://github.com/AlijonovUz/PostgresDB
6
6
  Author: Abdulbosit Alijonov
@@ -30,7 +30,7 @@ Oddiy va qulay Python wrapper PostgreSQL bazasi bilan ishlash uchun.
30
30
  pip install postgresdb3
31
31
  ```
32
32
 
33
- ## Foydalanish
33
+ ## Foydalanish (Sync)
34
34
 
35
35
  ``` python
36
36
  from postgresdb3 import PostgresDB
@@ -40,8 +40,8 @@ db = PostgresDB(
40
40
  database="mydb",
41
41
  user="postgres",
42
42
  password="mypassword",
43
- host="localhost",
44
- port=5432
43
+ host="localhost", # ixtiyoriy
44
+ port=5432 # ixtiyoriy
45
45
  )
46
46
 
47
47
  # Jadval yaratish
@@ -76,6 +76,61 @@ db.delete("users", "name", "Ali")
76
76
  db.drop("users")
77
77
  ```
78
78
 
79
+ ## Foydalanish (Async)
80
+
81
+ ```python
82
+ import asyncio
83
+ from postgresdb3 import AsyncPostgresDB
84
+
85
+ async def main():
86
+ # Bazaga ulanish
87
+ db = AsyncPostgresDB(
88
+ database="mydb",
89
+ user="postgres",
90
+ password="mypassword",
91
+ host="localhost", # ixtiyoriy
92
+ port=5432 # ixtiyoriy
93
+ )
94
+
95
+ # Jadval yaratish
96
+ await db.create("users", "id SERIAL PRIMARY KEY, name VARCHAR(100), age INT")
97
+
98
+ # Ma'lumot qo'shish
99
+ await db.insert("users", "name, age", ["Ali", 25])
100
+ await db.insert("users", "name, age", ["Vali", 30])
101
+
102
+ # Barcha ma'lumotlarni olish
103
+ users = await db.select("users")
104
+ print("Barcha foydalanuvchilar:", users)
105
+
106
+ # Bitta qatorni olish
107
+ user = await db.select("users", where=("name=$1", ["Ali"]), fetchone=True)
108
+ print("Foydalanuvchi Ali:", user)
109
+
110
+ # Shart bilan ma'lumot olish
111
+ adults = await db.select("users", where=("age > $1", [18]))
112
+ print("Kattalar:", adults)
113
+
114
+ # Bir nechta shart
115
+ specific_users = await db.select("users", where=("age > $1 AND name = $2", [18, "Ali"]))
116
+ print("Maxsus foydalanuvchi:", specific_users)
117
+
118
+ # Jadvaldagi ma'lumotni yangilash
119
+ await db.update("users", "age", 26, "name", "Ali")
120
+
121
+ # Ma'lumotni o'chirish
122
+ await db.delete("users", "name", "Ali")
123
+
124
+ # Jadvalni o'chirish
125
+ await db.drop("users")
126
+
127
+ # Connection poolni yopish
128
+ await db.close_pool()
129
+
130
+ # Asinxron loop ishga tushirish
131
+ asyncio.run(main())
132
+ ```
133
+
79
134
  ## Parametrlar va metodlar
80
135
 
81
136
  **PostgresDB(database, user, password, host="localhost", port=5432)**
@@ -8,7 +8,7 @@ Oddiy va qulay Python wrapper PostgreSQL bazasi bilan ishlash uchun.
8
8
  pip install postgresdb3
9
9
  ```
10
10
 
11
- ## Foydalanish
11
+ ## Foydalanish (Sync)
12
12
 
13
13
  ``` python
14
14
  from postgresdb3 import PostgresDB
@@ -18,8 +18,8 @@ db = PostgresDB(
18
18
  database="mydb",
19
19
  user="postgres",
20
20
  password="mypassword",
21
- host="localhost",
22
- port=5432
21
+ host="localhost", # ixtiyoriy
22
+ port=5432 # ixtiyoriy
23
23
  )
24
24
 
25
25
  # Jadval yaratish
@@ -54,6 +54,61 @@ db.delete("users", "name", "Ali")
54
54
  db.drop("users")
55
55
  ```
56
56
 
57
+ ## Foydalanish (Async)
58
+
59
+ ```python
60
+ import asyncio
61
+ from postgresdb3 import AsyncPostgresDB
62
+
63
+ async def main():
64
+ # Bazaga ulanish
65
+ db = AsyncPostgresDB(
66
+ database="mydb",
67
+ user="postgres",
68
+ password="mypassword",
69
+ host="localhost", # ixtiyoriy
70
+ port=5432 # ixtiyoriy
71
+ )
72
+
73
+ # Jadval yaratish
74
+ await db.create("users", "id SERIAL PRIMARY KEY, name VARCHAR(100), age INT")
75
+
76
+ # Ma'lumot qo'shish
77
+ await db.insert("users", "name, age", ["Ali", 25])
78
+ await db.insert("users", "name, age", ["Vali", 30])
79
+
80
+ # Barcha ma'lumotlarni olish
81
+ users = await db.select("users")
82
+ print("Barcha foydalanuvchilar:", users)
83
+
84
+ # Bitta qatorni olish
85
+ user = await db.select("users", where=("name=$1", ["Ali"]), fetchone=True)
86
+ print("Foydalanuvchi Ali:", user)
87
+
88
+ # Shart bilan ma'lumot olish
89
+ adults = await db.select("users", where=("age > $1", [18]))
90
+ print("Kattalar:", adults)
91
+
92
+ # Bir nechta shart
93
+ specific_users = await db.select("users", where=("age > $1 AND name = $2", [18, "Ali"]))
94
+ print("Maxsus foydalanuvchi:", specific_users)
95
+
96
+ # Jadvaldagi ma'lumotni yangilash
97
+ await db.update("users", "age", 26, "name", "Ali")
98
+
99
+ # Ma'lumotni o'chirish
100
+ await db.delete("users", "name", "Ali")
101
+
102
+ # Jadvalni o'chirish
103
+ await db.drop("users")
104
+
105
+ # Connection poolni yopish
106
+ await db.close_pool()
107
+
108
+ # Asinxron loop ishga tushirish
109
+ asyncio.run(main())
110
+ ```
111
+
57
112
  ## Parametrlar va metodlar
58
113
 
59
114
  **PostgresDB(database, user, password, host="localhost", port=5432)**
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: postgresdb3
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: Python uchun oddiy PostgreSQL wrapper
5
5
  Home-page: https://github.com/AlijonovUz/PostgresDB
6
6
  Author: Abdulbosit Alijonov
@@ -30,7 +30,7 @@ Oddiy va qulay Python wrapper PostgreSQL bazasi bilan ishlash uchun.
30
30
  pip install postgresdb3
31
31
  ```
32
32
 
33
- ## Foydalanish
33
+ ## Foydalanish (Sync)
34
34
 
35
35
  ``` python
36
36
  from postgresdb3 import PostgresDB
@@ -40,8 +40,8 @@ db = PostgresDB(
40
40
  database="mydb",
41
41
  user="postgres",
42
42
  password="mypassword",
43
- host="localhost",
44
- port=5432
43
+ host="localhost", # ixtiyoriy
44
+ port=5432 # ixtiyoriy
45
45
  )
46
46
 
47
47
  # Jadval yaratish
@@ -76,6 +76,61 @@ db.delete("users", "name", "Ali")
76
76
  db.drop("users")
77
77
  ```
78
78
 
79
+ ## Foydalanish (Async)
80
+
81
+ ```python
82
+ import asyncio
83
+ from postgresdb3 import AsyncPostgresDB
84
+
85
+ async def main():
86
+ # Bazaga ulanish
87
+ db = AsyncPostgresDB(
88
+ database="mydb",
89
+ user="postgres",
90
+ password="mypassword",
91
+ host="localhost", # ixtiyoriy
92
+ port=5432 # ixtiyoriy
93
+ )
94
+
95
+ # Jadval yaratish
96
+ await db.create("users", "id SERIAL PRIMARY KEY, name VARCHAR(100), age INT")
97
+
98
+ # Ma'lumot qo'shish
99
+ await db.insert("users", "name, age", ["Ali", 25])
100
+ await db.insert("users", "name, age", ["Vali", 30])
101
+
102
+ # Barcha ma'lumotlarni olish
103
+ users = await db.select("users")
104
+ print("Barcha foydalanuvchilar:", users)
105
+
106
+ # Bitta qatorni olish
107
+ user = await db.select("users", where=("name=$1", ["Ali"]), fetchone=True)
108
+ print("Foydalanuvchi Ali:", user)
109
+
110
+ # Shart bilan ma'lumot olish
111
+ adults = await db.select("users", where=("age > $1", [18]))
112
+ print("Kattalar:", adults)
113
+
114
+ # Bir nechta shart
115
+ specific_users = await db.select("users", where=("age > $1 AND name = $2", [18, "Ali"]))
116
+ print("Maxsus foydalanuvchi:", specific_users)
117
+
118
+ # Jadvaldagi ma'lumotni yangilash
119
+ await db.update("users", "age", 26, "name", "Ali")
120
+
121
+ # Ma'lumotni o'chirish
122
+ await db.delete("users", "name", "Ali")
123
+
124
+ # Jadvalni o'chirish
125
+ await db.drop("users")
126
+
127
+ # Connection poolni yopish
128
+ await db.close_pool()
129
+
130
+ # Asinxron loop ishga tushirish
131
+ asyncio.run(main())
132
+ ```
133
+
79
134
  ## Parametrlar va metodlar
80
135
 
81
136
  **PostgresDB(database, user, password, host="localhost", port=5432)**
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as f:
5
5
 
6
6
  setup(
7
7
  name="postgresdb3",
8
- version="0.2.0",
8
+ version="0.2.1",
9
9
  packages=find_packages(),
10
10
  install_requires=[
11
11
  "psycopg2>=2.9",
File without changes
File without changes