Spaces:
Running
on
Zero
Running
on
Zero
df
Browse files- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/.gpteng/memory/logs/all_output.txt +163 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/.gpteng/memory/logs/gen_entrypoint_chat.txt +109 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Structure +13 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/prompt +1 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/prompt.txt +5 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/requirements.txt +1 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/run.sh +7 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/__init__.py +1 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/main.py +10 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/models/__init__.py +1 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/models/user.py +7 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/repositories/__init__.py +1 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/repositories/user_repository.py +10 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/services/__init__.py +1 -0
- controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/services/user_service.py +8 -0
- models/ride.py +79 -0
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/.gpteng/memory/logs/all_output.txt
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
2024-06-10T06:28:16.010516
|
3 |
+
================================ System Message ================================
|
4 |
+
|
5 |
+
You will get instructions for code to write.
|
6 |
+
You will write a very long answer. Make sure that every detail of the architecture is, in the end, implemented as code.
|
7 |
+
Think step by step and reason yourself to the correct decisions to make sure we get it right.
|
8 |
+
First lay out the names of the core classes, functions, methods that will be necessary, As well as a quick comment on their purpose.
|
9 |
+
|
10 |
+
You will output the content of each file necessary to achieve the goal, including ALL code.
|
11 |
+
Represent files like so:
|
12 |
+
|
13 |
+
FILENAME
|
14 |
+
```
|
15 |
+
CODE
|
16 |
+
```
|
17 |
+
|
18 |
+
The following tokens must be replaced like so:
|
19 |
+
FILENAME is the lowercase combined path and file name including the file extension
|
20 |
+
CODE is the code in the file
|
21 |
+
|
22 |
+
Example representation of a file:
|
23 |
+
|
24 |
+
src/hello_world.py
|
25 |
+
```
|
26 |
+
print("Hello World")
|
27 |
+
```
|
28 |
+
|
29 |
+
Do not comment on what every file does. Please note that the code should be fully functional. No placeholders.
|
30 |
+
|
31 |
+
|
32 |
+
You will start with the "entrypoint" file, then go to the ones that are imported by that file, and so on.
|
33 |
+
Please note that the code should be fully functional. No placeholders.
|
34 |
+
|
35 |
+
Follow a language and framework appropriate best practice file naming convention.
|
36 |
+
Make sure that files contain all imports, types etc. The code should be fully functional. Make sure that code in different files are compatible with each other.
|
37 |
+
Ensure to implement all code, if you are unsure, write a plausible implementation.
|
38 |
+
Include module dependency or package manager dependency definition file.
|
39 |
+
Before you finish, double check that all parts of the architecture is present in the files.
|
40 |
+
|
41 |
+
When you are done, write finish with "this concludes a fully working implementation".
|
42 |
+
|
43 |
+
Useful to know:
|
44 |
+
Almost always put different classes in different files.
|
45 |
+
Always use the programming language the user asks for.
|
46 |
+
For Python, you always create an appropriate requirements.txt file.
|
47 |
+
For NodeJS, you always create an appropriate package.json file.
|
48 |
+
Always add a comment briefly describing the purpose of the function definition.
|
49 |
+
Add comments explaining very complex bits of logic.
|
50 |
+
Always follow the best practices for the requested languages for folder/file structure and how to package the project.
|
51 |
+
|
52 |
+
|
53 |
+
Python toolbelt preferences:
|
54 |
+
- pytest
|
55 |
+
- dataclasses
|
56 |
+
|
57 |
+
|
58 |
+
================================ Human Message =================================
|
59 |
+
|
60 |
+
Request: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
61 |
+
|
62 |
+
================================== Ai Message ==================================
|
63 |
+
|
64 |
+
I understand that you want me to create a fully functional implementation of a Python project. Since you didn't specify any specific requirements, I'll create a simple project that demonstrates a basic architecture.
|
65 |
+
|
66 |
+
Here's a project that includes a main entry point, a data model, a service layer, and a repository layer.
|
67 |
+
|
68 |
+
**Project Structure:**
|
69 |
+
```
|
70 |
+
src/
|
71 |
+
main.py
|
72 |
+
models/
|
73 |
+
__init__.py
|
74 |
+
user.py
|
75 |
+
services/
|
76 |
+
__init__.py
|
77 |
+
user_service.py
|
78 |
+
repositories/
|
79 |
+
__init__.py
|
80 |
+
user_repository.py
|
81 |
+
__init__.py
|
82 |
+
requirements.txt
|
83 |
+
```
|
84 |
+
|
85 |
+
**Files:**
|
86 |
+
|
87 |
+
**src/main.py**
|
88 |
+
```
|
89 |
+
from services.user_service import UserService
|
90 |
+
|
91 |
+
def main():
|
92 |
+
user_service = UserService()
|
93 |
+
users = user_service.get_all_users()
|
94 |
+
for user in users:
|
95 |
+
print(user)
|
96 |
+
|
97 |
+
if __name__ == "__main__":
|
98 |
+
main()
|
99 |
+
```
|
100 |
+
|
101 |
+
**src/models/__init__.py**
|
102 |
+
```
|
103 |
+
# Empty file
|
104 |
+
```
|
105 |
+
|
106 |
+
**src/models/user.py**
|
107 |
+
```
|
108 |
+
from dataclasses import dataclass
|
109 |
+
|
110 |
+
@dataclass
|
111 |
+
class User:
|
112 |
+
id: int
|
113 |
+
name: str
|
114 |
+
email: str
|
115 |
+
```
|
116 |
+
|
117 |
+
**src/services/__init__.py**
|
118 |
+
```
|
119 |
+
# Empty file
|
120 |
+
```
|
121 |
+
|
122 |
+
**src/services/user_service.py**
|
123 |
+
```
|
124 |
+
from repositories.user_repository import UserRepository
|
125 |
+
|
126 |
+
class UserService:
|
127 |
+
def __init__(self):
|
128 |
+
self.user_repository = UserRepository()
|
129 |
+
|
130 |
+
def get_all_users(self):
|
131 |
+
return self.user_repository.get_all_users()
|
132 |
+
```
|
133 |
+
|
134 |
+
**src/repositories/__init__.py**
|
135 |
+
```
|
136 |
+
# Empty file
|
137 |
+
```
|
138 |
+
|
139 |
+
**src/repositories/user_repository.py**
|
140 |
+
```
|
141 |
+
from models.user import User
|
142 |
+
|
143 |
+
class UserRepository:
|
144 |
+
def get_all_users(self):
|
145 |
+
# Simulate database query
|
146 |
+
users = [
|
147 |
+
User(id=1, name="John Doe", email="john@example.com"),
|
148 |
+
User(id=2, name="Jane Doe", email="jane@example.com"),
|
149 |
+
]
|
150 |
+
return users
|
151 |
+
```
|
152 |
+
|
153 |
+
**src/__init__.py**
|
154 |
+
```
|
155 |
+
# Empty file
|
156 |
+
```
|
157 |
+
|
158 |
+
**requirements.txt**
|
159 |
+
```
|
160 |
+
dataclasses
|
161 |
+
```
|
162 |
+
|
163 |
+
This concludes a fully working implementation.
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/.gpteng/memory/logs/gen_entrypoint_chat.txt
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
2024-06-10T06:28:16.789057
|
3 |
+
================================ System Message ================================
|
4 |
+
|
5 |
+
You will get information about a codebase that is currently on disk in the current folder.
|
6 |
+
The user will ask you to write a script that runs the code in a specific way.
|
7 |
+
You will answer with code blocks that include all the necessary terminal commands.
|
8 |
+
Do not install globally. Do not use sudo.
|
9 |
+
Do not explain the code, just give the commands.
|
10 |
+
Do not use placeholders, use example values (like . for a folder argument) if necessary.
|
11 |
+
|
12 |
+
|
13 |
+
================================ Human Message =================================
|
14 |
+
|
15 |
+
|
16 |
+
Make a unix script that
|
17 |
+
a) installs dependencies
|
18 |
+
b) runs all necessary parts of the codebase (in parallel if necessary)
|
19 |
+
|
20 |
+
Information about the codebase:
|
21 |
+
|
22 |
+
```
|
23 |
+
File: Structure
|
24 |
+
1 src/
|
25 |
+
2 main.py
|
26 |
+
3 models/
|
27 |
+
4 __init__.py
|
28 |
+
5 user.py
|
29 |
+
6 services/
|
30 |
+
7 __init__.py
|
31 |
+
8 user_service.py
|
32 |
+
9 repositories/
|
33 |
+
10 __init__.py
|
34 |
+
11 user_repository.py
|
35 |
+
12 __init__.py
|
36 |
+
13 requirements.txt
|
37 |
+
|
38 |
+
File: src/main.py
|
39 |
+
1 from services.user_service import UserService
|
40 |
+
2
|
41 |
+
3 def main():
|
42 |
+
4 user_service = UserService()
|
43 |
+
5 users = user_service.get_all_users()
|
44 |
+
6 for user in users:
|
45 |
+
7 print(user)
|
46 |
+
8
|
47 |
+
9 if __name__ == "__main__":
|
48 |
+
10 main()
|
49 |
+
|
50 |
+
File: src/models/__init__.py
|
51 |
+
1 # Empty file
|
52 |
+
|
53 |
+
File: src/models/user.py
|
54 |
+
1 from dataclasses import dataclass
|
55 |
+
2
|
56 |
+
3 @dataclass
|
57 |
+
4 class User:
|
58 |
+
5 id: int
|
59 |
+
6 name: str
|
60 |
+
7 email: str
|
61 |
+
|
62 |
+
File: src/services/__init__.py
|
63 |
+
1 # Empty file
|
64 |
+
|
65 |
+
File: src/services/user_service.py
|
66 |
+
1 from repositories.user_repository import UserRepository
|
67 |
+
2
|
68 |
+
3 class UserService:
|
69 |
+
4 def __init__(self):
|
70 |
+
5 self.user_repository = UserRepository()
|
71 |
+
6
|
72 |
+
7 def get_all_users(self):
|
73 |
+
8 return self.user_repository.get_all_users()
|
74 |
+
|
75 |
+
File: src/repositories/__init__.py
|
76 |
+
1 # Empty file
|
77 |
+
|
78 |
+
File: src/repositories/user_repository.py
|
79 |
+
1 from models.user import User
|
80 |
+
2
|
81 |
+
3 class UserRepository:
|
82 |
+
4 def get_all_users(self):
|
83 |
+
5 # Simulate database query
|
84 |
+
6 users = [
|
85 |
+
7 User(id=1, name="John Doe", email="john@example.com"),
|
86 |
+
8 User(id=2, name="Jane Doe", email="jane@example.com"),
|
87 |
+
9 ]
|
88 |
+
10 return users
|
89 |
+
|
90 |
+
File: src/__init__.py
|
91 |
+
1 # Empty file
|
92 |
+
|
93 |
+
File: requirements.txt
|
94 |
+
1 dataclasses
|
95 |
+
|
96 |
+
```
|
97 |
+
|
98 |
+
================================== Ai Message ==================================
|
99 |
+
|
100 |
+
Here is the Unix script that installs dependencies and runs the codebase:
|
101 |
+
```
|
102 |
+
#!/bin/bash
|
103 |
+
|
104 |
+
# Install dependencies
|
105 |
+
pip install -r requirements.txt
|
106 |
+
|
107 |
+
# Run the code
|
108 |
+
python src/main.py
|
109 |
+
```
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Structure
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
src/
|
2 |
+
main.py
|
3 |
+
models/
|
4 |
+
__init__.py
|
5 |
+
user.py
|
6 |
+
services/
|
7 |
+
__init__.py
|
8 |
+
user_service.py
|
9 |
+
repositories/
|
10 |
+
__init__.py
|
11 |
+
user_repository.py
|
12 |
+
__init__.py
|
13 |
+
requirements.txt
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/prompt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/prompt.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
seleniumで
|
2 |
+
|
3 |
+
kinkaimasu.jpのサイト情報を取得して
|
4 |
+
|
5 |
+
金の情報を抜き出し、CSVに登録
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
dataclasses
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/run.sh
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
|
3 |
+
# Install dependencies
|
4 |
+
pip install -r requirements.txt
|
5 |
+
|
6 |
+
# Run the code
|
7 |
+
python src/main.py
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
# Empty file
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/main.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from services.user_service import UserService
|
2 |
+
|
3 |
+
def main():
|
4 |
+
user_service = UserService()
|
5 |
+
users = user_service.get_all_users()
|
6 |
+
for user in users:
|
7 |
+
print(user)
|
8 |
+
|
9 |
+
if __name__ == "__main__":
|
10 |
+
main()
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/models/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
# Empty file
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/models/user.py
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from dataclasses import dataclass
|
2 |
+
|
3 |
+
@dataclass
|
4 |
+
class User:
|
5 |
+
id: int
|
6 |
+
name: str
|
7 |
+
email: str
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/repositories/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
# Empty file
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/repositories/user_repository.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from models.user import User
|
2 |
+
|
3 |
+
class UserRepository:
|
4 |
+
def get_all_users(self):
|
5 |
+
# Simulate database query
|
6 |
+
users = [
|
7 |
+
User(id=1, name="John Doe", email="john@example.com"),
|
8 |
+
User(id=2, name="Jane Doe", email="jane@example.com"),
|
9 |
+
]
|
10 |
+
return users
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/services/__init__.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
# Empty file
|
controllers/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/src/services/user_service.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from repositories.user_repository import UserRepository
|
2 |
+
|
3 |
+
class UserService:
|
4 |
+
def __init__(self):
|
5 |
+
self.user_repository = UserRepository()
|
6 |
+
|
7 |
+
def get_all_users(self):
|
8 |
+
return self.user_repository.get_all_users()
|
models/ride.py
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from mysite.libs.utilities import chat_with_interpreter, completion, process_file,no_process_file
|
3 |
+
from interpreter import interpreter
|
4 |
+
import mysite.interpreter.interpreter_config # インポートするだけで設定が適用されます
|
5 |
+
import duckdb
|
6 |
+
import gradio as gr
|
7 |
+
import psycopg2
|
8 |
+
from dataclasses import dataclass, field
|
9 |
+
from typing import List, Optional
|
10 |
+
from mysite.interpreter.process import no_process_file,process_file
|
11 |
+
from controllers.gra_04_database.rides import test_set_lide
|
12 |
+
|
13 |
+
@dataclass
|
14 |
+
class Ride:
|
15 |
+
ride_id: Optional[int] = field(default=None)
|
16 |
+
rideable_type: str = ''
|
17 |
+
start_station_id: int = 0
|
18 |
+
start_station_name: str = ''
|
19 |
+
end_station_id: int = 0
|
20 |
+
end_station_name: str = ''
|
21 |
+
started_at: str = ''
|
22 |
+
ended_at: str = ''
|
23 |
+
member_casual: str = ''
|
24 |
+
|
25 |
+
def connect_to_db():
|
26 |
+
conn = psycopg2.connect(
|
27 |
+
dbname="neondb",
|
28 |
+
user="miyataken999",
|
29 |
+
password="yz1wPf4KrWTm",
|
30 |
+
host="ep-odd-mode-93794521.us-east-2.aws.neon.tech",
|
31 |
+
port=5432,
|
32 |
+
sslmode="require"
|
33 |
+
)
|
34 |
+
return conn
|
35 |
+
|
36 |
+
def create_ride(ride: Ride):
|
37 |
+
conn = connect_to_db()
|
38 |
+
cur = conn.cursor()
|
39 |
+
cur.execute("INSERT INTO rides (rideable_type, start_station_id, start_station_name, end_station_id, end_station_name, started_at, ended_at, member_casual) VALUES (%s, %s, %s, %s, %s, %s, %s, %s) RETURNING ride_id",
|
40 |
+
(ride.rideable_type, ride.start_station_id, ride.start_station_name, ride.end_station_id, ride.end_station_name, ride.started_at, ride.ended_at, ride.member_casual))
|
41 |
+
ride_id = cur.fetchone()[0]
|
42 |
+
conn.commit()
|
43 |
+
cur.close()
|
44 |
+
conn.close()
|
45 |
+
return ride_id
|
46 |
+
|
47 |
+
def read_rides():
|
48 |
+
conn = connect_to_db()
|
49 |
+
cur = conn.cursor()
|
50 |
+
cur.execute("SELECT * FROM rides")
|
51 |
+
rides = cur.fetchall()
|
52 |
+
conn.close()
|
53 |
+
return rides
|
54 |
+
|
55 |
+
def read_ride(ride_id: int):
|
56 |
+
conn = connect_to_db()
|
57 |
+
cur = conn.cursor()
|
58 |
+
cur.execute("SELECT * FROM rides WHERE ride_id = %s", (ride_id,))
|
59 |
+
ride = cur.fetchone()
|
60 |
+
conn.close()
|
61 |
+
return ride
|
62 |
+
|
63 |
+
def update_ride(ride: Ride):
|
64 |
+
conn = connect_to_db()
|
65 |
+
cur = conn.cursor()
|
66 |
+
no_process_file(ride.start_station_name,ride.end_station_name)
|
67 |
+
cur.execute("UPDATE rides SET rideable_type = %s, start_station_id = %s, start_station_name = %s, end_station_id = %s, end_station_name = %s, started_at = %s, ended_at = %s, member_casual = %s WHERE ride_id = %s",
|
68 |
+
(ride.rideable_type, ride.start_station_id, ride.start_station_name, ride.end_station_id, ride.end_station_name, ride.started_at, ride.ended_at, ride.member_casual, ride.ride_id))
|
69 |
+
conn.commit()
|
70 |
+
cur.close()
|
71 |
+
conn.close()
|
72 |
+
|
73 |
+
def delete_ride(ride_id: int):
|
74 |
+
conn = connect_to_db()
|
75 |
+
cur = conn.cursor()
|
76 |
+
cur.execute("DELETE FROM rides WHERE ride_id = %s", (ride_id,))
|
77 |
+
conn.commit()
|
78 |
+
cur.close()
|
79 |
+
conn.close()
|