dmddl 0.2.22__py3-none-any.whl → 0.2.24__py3-none-any.whl

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.
@@ -0,0 +1,2 @@
1
+ # Automatically created by ruff.
2
+ *
@@ -0,0 +1 @@
1
+ Signature: 8a477f597d28d172789f06886806bc55
dmddl/cli.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import asyncio
2
+ from idlelib.help import copy_strip
2
3
 
3
4
  import questionary
4
5
  from requests.exceptions import ProxyError
@@ -34,15 +35,14 @@ def ask_api_key():
34
35
 
35
36
  def make_query(provider, api_key, prompt, proxies = None):
36
37
  console = Console()
37
- with console.status("[bold blue]Making query. Wait for result..."):
38
- if provider:
39
- if provider == "OpenAI":
40
- response = openai_request(prompt=base_prompt+prompt, api_key=api_key, proxies=proxies)
41
- return response
38
+ if provider:
39
+ if provider == "OpenAI":
40
+ response = openai_request(prompt=base_prompt+prompt, api_key=api_key, proxies=proxies, console=console)
41
+ return response
42
42
 
43
- raise Exception("LLM Provider not found")
44
- else:
45
- raise Exception("Use -c (--config) to configurate app and set LLM provider.")
43
+ raise Exception("LLM Provider not found")
44
+ else:
45
+ raise Exception("Use -c (--config) to configurate app and set LLM provider.")
46
46
 
47
47
 
48
48
  def write_output_file(data):
@@ -128,17 +128,14 @@ def main():
128
128
  proxies = None
129
129
 
130
130
  if args.proxy:
131
- with console.status("[blue bold] Searching for valid proxies..."):
132
- proxies = asyncio.run(get_valid_proxies())
133
- if proxies:
134
- print("[bold blue] Proxy found!")
135
- for proxy in proxies:
136
- print(f"[yellow bold]- {proxy}")
137
- else:
138
- raise Exception("Proxy does not found :( \n Try again later. (it really helps)")
139
-
140
-
141
-
131
+ console = Console()
132
+ try:
133
+ proxies = asyncio.run(get_valid_proxies(console))
134
+ print("[green bold]\n\tVALID PROXIES")
135
+ for proxy in proxies:
136
+ print(f"[green bold]- {proxy}")
137
+ except:
138
+ pass
142
139
  confirmation, user_prompt = input_prompt_dialogue(args)
143
140
 
144
141
  if confirmation:
dmddl/config/.env ADDED
@@ -0,0 +1,2 @@
1
+ DMDDL_CUR_PROVIDER='OpenAI'
2
+ DMDDL_LLM_KEY='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'
dmddl/config/proxy.py CHANGED
@@ -2,6 +2,8 @@ import asyncio
2
2
  from bs4 import BeautifulSoup
3
3
  import aiohttp
4
4
  import requests
5
+ from rich import print
6
+ from rich.console import Console
5
7
 
6
8
 
7
9
  def get_proxy_list():
@@ -12,24 +14,36 @@ def get_proxy_list():
12
14
  table = soup.find('table')
13
15
  for row in table.tbody.find_all('tr'):
14
16
  cols = row.find_all('td')
15
- if cols[4].text == 'elite proxy' and cols[6].text == 'yes':
17
+ if (cols[4].text == 'elite proxy' or cols[4].text == 'anonymous') and cols[6].text == 'yes':
16
18
  proxies.append(f"http://{cols[0].text}:{cols[1].text}")
17
-
18
19
  return proxies
19
20
 
20
21
 
21
- async def test_request(url, proxy, session):
22
+ async def is_valid_proxy(url, proxy, session):
22
23
  try:
23
- async with session.get(url, proxy=proxy, timeout=15) as response:
24
+ async with session.get(url, proxy=proxy, timeout=5) as response:
24
25
  return proxy
25
- except:
26
- pass
26
+
27
+ except (aiohttp.ClientError, ConnectionResetError, asyncio.TimeoutError):
28
+ return None
27
29
 
28
30
 
29
- async def get_valid_proxies():
31
+ async def get_valid_proxies(console: Console):
30
32
  proxies = get_proxy_list()
31
- url = "https://platform.openai.com"
32
- async with aiohttp.ClientSession() as session:
33
- tasks = [test_request(url, proxy, session) for proxy in proxies]
34
- good_proxies = [proxy for proxy in await asyncio.gather(*tasks) if proxy]
35
- return good_proxies
33
+ url = "https://api.openai.com/v1/chat/completions"
34
+ valid_proxies = []
35
+
36
+ with console.status("[blue bold]Checking proxies...") as status:
37
+ async with aiohttp.ClientSession() as session:
38
+ tasks = [is_valid_proxy(url, proxy, session) for proxy in proxies]
39
+ for i, task in enumerate(asyncio.as_completed(tasks), 1):
40
+ proxy = await task
41
+ if proxy:
42
+ valid_proxies.append(proxy)
43
+ console.print(f"[green bold]✅ Valid proxy: {proxy}")
44
+ else:
45
+ console.print(f"[red bold]❌ Invalid proxy: {proxies[i - 1]}")
46
+ status.update(f"[blue bold]Checked {i}/{len(proxies)} proxies | Valid: {len(valid_proxies)}")
47
+
48
+ return valid_proxies
49
+
dmddl/input.txt ADDED
@@ -0,0 +1 @@
1
+ test
dmddl/models/llm.py CHANGED
@@ -1,7 +1,10 @@
1
+ from http.client import RemoteDisconnected
2
+
1
3
  import requests
4
+ from requests.exceptions import ProxyError
2
5
  from rich import print
3
6
 
4
- def openai_request(prompt, api_key, proxies = None):
7
+ def openai_request(prompt, api_key, console, proxies = None):
5
8
  headers = {
6
9
  "Authorization": f"Bearer {api_key}",
7
10
  "Content-Type": "application/json"
@@ -17,21 +20,21 @@ def openai_request(prompt, api_key, proxies = None):
17
20
  ]
18
21
  }
19
22
 
20
- if proxies:
21
- for proxy in proxies:
22
- try:
23
- print(f"[yellow bold]Using proxy: {proxy}")
24
- req_proxies = {
25
- "https": proxy
26
- }
27
- response = requests.post(url=url, headers=headers, json=data, proxies = req_proxies)
28
- if response.status_code == 200:
29
- break
30
- except:
31
- pass
32
-
33
- else:
34
- response = requests.post(url=url, headers=headers, json=data)
23
+ with console.status("[bold blue]Making query. Wait for result..."):
24
+ if proxies:
25
+ for proxy in proxies:
26
+ try:
27
+ req_proxies = {
28
+ "https": proxy
29
+ }
30
+ print(f"[blue bold]Using proxy: {proxy}")
31
+ response = requests.post(url=url, headers=headers, json=data, proxies = req_proxies)
32
+ if response.status_code == 200:
33
+ break
34
+ except:
35
+ print(f"\n[red bold]Proxy error... Trying next proxy")
36
+ else:
37
+ response = requests.post(url=url, headers=headers, json=data)
35
38
 
36
39
 
37
40
  if response.status_code == 200:
dmddl/output.txt ADDED
@@ -0,0 +1,37 @@
1
+ -- TABLE: users (15 records)
2
+ INSERT INTO users (user_id, username, email) VALUES
3
+ (1, 'alice_johnson', 'alice.johnson@example.com'),
4
+ (2, 'bob_smith', 'bob.smith@example.com'),
5
+ (3, 'charlie_brown', 'charlie.brown@example.com'),
6
+ (4, 'diane_green', 'diane.green@example.com'),
7
+ (5, 'edward_white', 'edward.white@example.com'),
8
+ (6, 'frank_black', 'frank.black@example.com'),
9
+ (7, 'grace_kelly', 'grace.kelly@example.com'),
10
+ (8, 'henry_ford', 'henry.ford@example.com'),
11
+ (9, 'iris_davis', 'iris.davis@example.com'),
12
+ (10, 'jack_martin', 'jack.martin@example.com'),
13
+ (11, 'karen_williams', 'karen.williams@example.com'),
14
+ (12, 'louis_james', 'louis.james@example.com'),
15
+ (13, 'maria_anderson', 'maria.anderson@example.com'),
16
+ (14, 'nancy_thomas', 'nancy.thomas@example.com'),
17
+ (15, 'oscar_harrison', 'oscar.harrison@example.com');
18
+
19
+ -- TABLE: orders (15 records)
20
+ INSERT INTO orders (order_id, user_id, order_date) VALUES
21
+ (1, 1, '2023-03-01'),
22
+ (2, 2, '2023-03-02'),
23
+ (3, 3, '2023-03-03'),
24
+ (4, 4, '2023-03-04'),
25
+ (5, 5, '2023-03-05'),
26
+ (6, 6, '2023-03-06'),
27
+ (7, 7, '2023-03-07'),
28
+ (8, 8, '2023-03-08'),
29
+ (9, 9, '2023-03-09'),
30
+ (10, 10, '2023-03-10'),
31
+ (11, 11, '2023-03-11'),
32
+ (12, 12, '2023-03-12'),
33
+ (13, 13, '2023-03-13'),
34
+ (14, 14, '2023-03-14'),
35
+ (15, 15, '2023-03-15');
36
+
37
+ -- WARNING: Ensure user_id in orders exists in users.
dmddl/requirements.txt ADDED
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dmddl
3
- Version: 0.2.22
3
+ Version: 0.2.24
4
4
  Summary: cli tool for creating insert script from ddl script
5
5
  License: MIT
6
6
  Author: HoJLter
@@ -29,7 +29,7 @@ Description-Content-Type: text/markdown
29
29
  <img src=".github/dmddl%20logo_4.png" align="center">
30
30
 
31
31
  <h3 align="center">
32
- CLI app that generates insertion script from DDL
32
+ CLI tool that generates insertion script from DDL
33
33
  </h3>
34
34
 
35
35
  ---
@@ -0,0 +1,20 @@
1
+ dmddl/.ruff_cache/.gitignore,sha256=njpg8ebsSuYCFcEdVLFxOSdF7CXp3e1DPVvZITY68xY,35
2
+ dmddl/.ruff_cache/0.11.9/1354378795363258161,sha256=L3hDS6FRTSJLyZSY-GZ75mpl9wiuFnMN9ESaojdTGoM,465
3
+ dmddl/.ruff_cache/CACHEDIR.TAG,sha256=WVMVbX4MVkpCclExbq8m-IcOZIOuIZf5FrYw5Pk-Ma4,43
4
+ dmddl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ dmddl/cli.py,sha256=Yfc8D5SuoPNeg4Emat6vpURAL6Fgpo45OOX2WBVgu30,4334
6
+ dmddl/config/.env,sha256=ViORk1v0SOwLiZUBUOsWZUXgHnsJe67qXq7cklz9Z_4,211
7
+ dmddl/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ dmddl/config/proxy.py,sha256=-6DfuggcXwDjtx8jbOMHy370AvM_t3kYc67q68CCqRM,1763
9
+ dmddl/config/settings.py,sha256=2xRMW9sjc3aro2QUGLMhKQGdAuCMkc5n6G23iXrkyMo,1261
10
+ dmddl/input.txt,sha256=n4bQgYhMfWWaL-qgxVrQFaO_TxsrC4Is0V1sFbDwCgg,4
11
+ dmddl/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ dmddl/models/llm.py,sha256=icEQKHstgbRLRU6rEmg6syMjkGkGATjXxUBh-L1SjVE,1628
13
+ dmddl/models/prompt.py,sha256=7cjWC-mQJR32jc0a0GsyoYDZWROB57Yk4Wy4nRsiFoM,1923
14
+ dmddl/output.txt,sha256=oVtNzMeEcoJ3UUtsiyugFB9s3mYLt0UyuEs5ppXb-WY,1337
15
+ dmddl/requirements.txt,sha256=aPA3NBpypHOiXAK9MwfzIDhPIKxtB71s4yCeAXvbs1k,2046
16
+ dmddl-0.2.24.dist-info/entry_points.txt,sha256=87tyUAFcB9RYRLhYyxroZxcTho-o3IGXnMM4uMGKdV4,40
17
+ dmddl-0.2.24.dist-info/LICENSE,sha256=C--Tlk2EXyLEz1DSTQFKOo-WblCPTsxPcd8t63NCauw,1090
18
+ dmddl-0.2.24.dist-info/METADATA,sha256=NcFMrWc8gkQbEWRvnoE1hsnUXwX9tIIbpqlNxT4nxYI,1779
19
+ dmddl-0.2.24.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
20
+ dmddl-0.2.24.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- dmddl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- dmddl/cli.py,sha256=rUySIisltidK-S31Q33WYdtQrKlxESDYeCuBAIjDpWY,4528
3
- dmddl/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- dmddl/config/proxy.py,sha256=SSMviuSlJ9l8C_-nT2vcxKEWUBJoaAweszVehzwDYUU,1063
5
- dmddl/config/settings.py,sha256=2xRMW9sjc3aro2QUGLMhKQGdAuCMkc5n6G23iXrkyMo,1261
6
- dmddl/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- dmddl/models/llm.py,sha256=ruW57MEwscWtCWe6MvfGP0FGvuRJlVWM12c-W0IS1_c,1354
8
- dmddl/models/prompt.py,sha256=7cjWC-mQJR32jc0a0GsyoYDZWROB57Yk4Wy4nRsiFoM,1923
9
- dmddl-0.2.22.dist-info/entry_points.txt,sha256=87tyUAFcB9RYRLhYyxroZxcTho-o3IGXnMM4uMGKdV4,40
10
- dmddl-0.2.22.dist-info/LICENSE,sha256=C--Tlk2EXyLEz1DSTQFKOo-WblCPTsxPcd8t63NCauw,1090
11
- dmddl-0.2.22.dist-info/METADATA,sha256=ws5O6SMAvnojSYDxof44NDlp_YLGjks3xU_tyNRmJi0,1778
12
- dmddl-0.2.22.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
13
- dmddl-0.2.22.dist-info/RECORD,,
File without changes