dmddl 0.2.22__tar.gz → 0.2.24__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.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
  ---
@@ -10,7 +10,7 @@
10
10
  <img src=".github/dmddl%20logo_4.png" align="center">
11
11
 
12
12
  <h3 align="center">
13
- CLI app that generates insertion script from DDL
13
+ CLI tool that generates insertion script from DDL
14
14
  </h3>
15
15
 
16
16
  ---
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dmddl"
3
- version = "0.2.22"
3
+ version = "0.2.24"
4
4
  description = "cli tool for creating insert script from ddl script"
5
5
  authors = [
6
6
  {name = "HoJLter",email = "hojlter.work@gmail.com"}
@@ -0,0 +1,2 @@
1
+ # Automatically created by ruff.
2
+ *
@@ -0,0 +1 @@
1
+ Signature: 8a477f597d28d172789f06886806bc55
@@ -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:
@@ -0,0 +1,2 @@
1
+ DMDDL_CUR_PROVIDER='OpenAI'
2
+ DMDDL_LLM_KEY='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'
@@ -0,0 +1,49 @@
1
+ import asyncio
2
+ from bs4 import BeautifulSoup
3
+ import aiohttp
4
+ import requests
5
+ from rich import print
6
+ from rich.console import Console
7
+
8
+
9
+ def get_proxy_list():
10
+ url = "https://free-proxy-list.net/"
11
+ response = requests.get(url)
12
+ soup = BeautifulSoup(response.text, 'html.parser')
13
+ proxies = []
14
+ table = soup.find('table')
15
+ for row in table.tbody.find_all('tr'):
16
+ cols = row.find_all('td')
17
+ if (cols[4].text == 'elite proxy' or cols[4].text == 'anonymous') and cols[6].text == 'yes':
18
+ proxies.append(f"http://{cols[0].text}:{cols[1].text}")
19
+ return proxies
20
+
21
+
22
+ async def is_valid_proxy(url, proxy, session):
23
+ try:
24
+ async with session.get(url, proxy=proxy, timeout=5) as response:
25
+ return proxy
26
+
27
+ except (aiohttp.ClientError, ConnectionResetError, asyncio.TimeoutError):
28
+ return None
29
+
30
+
31
+ async def get_valid_proxies(console: Console):
32
+ proxies = get_proxy_list()
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
+
@@ -0,0 +1 @@
1
+ test
@@ -0,0 +1,50 @@
1
+ from http.client import RemoteDisconnected
2
+
3
+ import requests
4
+ from requests.exceptions import ProxyError
5
+ from rich import print
6
+
7
+ def openai_request(prompt, api_key, console, proxies = None):
8
+ headers = {
9
+ "Authorization": f"Bearer {api_key}",
10
+ "Content-Type": "application/json"
11
+ }
12
+ url = "https://api.openai.com/v1/chat/completions"
13
+ data = {
14
+ 'model': 'gpt-4o-mini',
15
+ 'messages':[
16
+ {
17
+ 'role': 'developer',
18
+ 'content': prompt
19
+ }
20
+ ]
21
+ }
22
+
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)
38
+
39
+
40
+ if response.status_code == 200:
41
+ return True, response.json()['choices'][0]['message']['content']
42
+
43
+ elif response.status_code == 401:
44
+ return False, ("Your api key is incorrect. \n"
45
+ "Use -c (--config) to configurate app and set new API key.")
46
+
47
+ else:
48
+ return False, response.json()['error']['message']
49
+
50
+
@@ -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.
Binary file
@@ -1,35 +0,0 @@
1
- import asyncio
2
- from bs4 import BeautifulSoup
3
- import aiohttp
4
- import requests
5
-
6
-
7
- def get_proxy_list():
8
- url = "https://free-proxy-list.net/"
9
- response = requests.get(url)
10
- soup = BeautifulSoup(response.text, 'html.parser')
11
- proxies = []
12
- table = soup.find('table')
13
- for row in table.tbody.find_all('tr'):
14
- cols = row.find_all('td')
15
- if cols[4].text == 'elite proxy' and cols[6].text == 'yes':
16
- proxies.append(f"http://{cols[0].text}:{cols[1].text}")
17
-
18
- return proxies
19
-
20
-
21
- async def test_request(url, proxy, session):
22
- try:
23
- async with session.get(url, proxy=proxy, timeout=15) as response:
24
- return proxy
25
- except:
26
- pass
27
-
28
-
29
- async def get_valid_proxies():
30
- 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
@@ -1,47 +0,0 @@
1
- import requests
2
- from rich import print
3
-
4
- def openai_request(prompt, api_key, proxies = None):
5
- headers = {
6
- "Authorization": f"Bearer {api_key}",
7
- "Content-Type": "application/json"
8
- }
9
- url = "https://api.openai.com/v1/chat/completions"
10
- data = {
11
- 'model': 'gpt-4o-mini',
12
- 'messages':[
13
- {
14
- 'role': 'developer',
15
- 'content': prompt
16
- }
17
- ]
18
- }
19
-
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)
35
-
36
-
37
- if response.status_code == 200:
38
- return True, response.json()['choices'][0]['message']['content']
39
-
40
- elif response.status_code == 401:
41
- return False, ("Your api key is incorrect. \n"
42
- "Use -c (--config) to configurate app and set new API key.")
43
-
44
- else:
45
- return False, response.json()['error']['message']
46
-
47
-
File without changes
File without changes