kenken999 commited on
Commit
8e3961e
1 Parent(s): 886d8e9

move tesets

Browse files
gpt-crawler DELETED
@@ -1 +0,0 @@
1
- Subproject commit 892cd9d61fcce1402675214d147c74afc662329a
 
 
myproject/requirements.txt DELETED
@@ -1,2 +0,0 @@
1
- pytest==7.1.2
2
- dataclasses==0.8
 
 
 
projects/example/.gpteng/memory/logs/all_output.txt DELETED
@@ -1,328 +0,0 @@
1
-
2
- 2024-06-01T15:39:52.837682
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: duckdbのサンプルの作成
61
- sample.csvを作成して その内容にCRUD
62
-
63
- ================================== Ai Message ==================================
64
-
65
- Here is a Python implementation using DuckDB and Pytest for testing.
66
-
67
- **requirements.txt**
68
- ```
69
- duckdb
70
- pytest
71
- ```
72
-
73
- **sample.csv**
74
- ```
75
- id,name,age
76
- 1,Alice,25
77
- 2,Bob,30
78
- 3,Charlie,35
79
- ```
80
-
81
- **duckdb_manager.py**
82
- ```
83
- import duckdb
84
-
85
- class DuckDBManager:
86
- def __init__(self, db_path):
87
- self.db_path = db_path
88
- self.conn = duckdb.connect(database=self.db_path)
89
-
90
- def create_table(self, table_name, columns):
91
- query = f"CREATE TABLE IF NOT EXISTS {table_name} ({', '.join(columns)})"
92
- self.conn.execute(query)
93
-
94
- def insert(self, table_name, values):
95
- query = f"INSERT INTO {table_name} VALUES ({', '.join(['?' for _ in values])})"
96
- self.conn.execute(query, values)
97
-
98
- def select(self, table_name, columns):
99
- query = f"SELECT {', '.join(columns)} FROM {table_name}"
100
- return self.conn.execute(query).fetchall()
101
-
102
- def update(self, table_name, set_column, set_value, where_column, where_value):
103
- query = f"UPDATE {table_name} SET {set_column} = ? WHERE {where_column} = ?"
104
- self.conn.execute(query, (set_value, where_value))
105
-
106
- def delete(self, table_name, where_column, where_value):
107
- query = f"DELETE FROM {table_name} WHERE {where_column} = ?"
108
- self.conn.execute(query, (where_value,))
109
-
110
- def close(self):
111
- self.conn.close()
112
- ```
113
-
114
- **crud_operations.py**
115
- ```
116
- from duckdb_manager import DuckDBManager
117
-
118
- class CRUDOperations:
119
- def __init__(self, db_path):
120
- self.db_manager = DuckDBManager(db_path)
121
-
122
- def create(self, table_name, columns, values):
123
- self.db_manager.create_table(table_name, columns)
124
- self.db_manager.insert(table_name, values)
125
-
126
- def read(self, table_name, columns):
127
- return self.db_manager.select(table_name, columns)
128
-
129
- def update(self, table_name, set_column, set_value, where_column, where_value):
130
- self.db_manager.update(table_name, set_column, set_value, where_column, where_value)
131
-
132
- def delete(self, table_name, where_column, where_value):
133
- self.db_manager.delete(table_name, where_column, where_value)
134
- ```
135
-
136
- **test_crud_operations.py**
137
- ```
138
- import pytest
139
- from crud_operations import CRUDOperations
140
-
141
- @pytest.fixture
142
- def crud_operations():
143
- return CRUDOperations('sample.db')
144
-
145
- def test_create(crud_operations):
146
- crud_operations.create('users', ['id INTEGER', 'name TEXT', 'age INTEGER'], (1, 'Alice', 25))
147
- assert crud_operations.read('users', ['*']) == [(1, 'Alice', 25)]
148
-
149
- def test_read(crud_operations):
150
- crud_operations.create('users', ['id INTEGER', 'name TEXT', 'age INTEGER'], (1, 'Alice', 25))
151
- assert crud_operations.read('users', ['*']) == [(1, 'Alice', 25)]
152
-
153
- def test_update(crud_operations):
154
- crud_operations.create('users', ['id INTEGER', 'name TEXT', 'age INTEGER'], (1, 'Alice', 25))
155
- crud_operations.update('users', 'age', 30, 'id', 1)
156
- assert crud_operations.read('users', ['*']) == [(1, 'Alice', 30)]
157
-
158
- def test_delete(crud_operations):
159
- crud_operations.create('users', ['id INTEGER', 'name TEXT', 'age INTEGER'], (1, 'Alice', 25))
160
- crud_operations.delete('users', 'id', 1)
161
- assert crud_operations.read('users', ['*']) == []
162
- ```
163
-
164
- This concludes a fully working implementation.
165
-
166
- 2024-06-01T15:40:48.609923
167
- ================================ System Message ================================
168
-
169
- You will get instructions for code to write.
170
- You will write a very long answer. Make sure that every detail of the architecture is, in the end, implemented as code.
171
- Think step by step and reason yourself to the correct decisions to make sure we get it right.
172
- First lay out the names of the core classes, functions, methods that will be necessary, As well as a quick comment on their purpose.
173
-
174
- You will output the content of each file necessary to achieve the goal, including ALL code.
175
- Represent files like so:
176
-
177
- FILENAME
178
- ```
179
- CODE
180
- ```
181
-
182
- The following tokens must be replaced like so:
183
- FILENAME is the lowercase combined path and file name including the file extension
184
- CODE is the code in the file
185
-
186
- Example representation of a file:
187
-
188
- src/hello_world.py
189
- ```
190
- print("Hello World")
191
- ```
192
-
193
- Do not comment on what every file does. Please note that the code should be fully functional. No placeholders.
194
-
195
-
196
- You will start with the "entrypoint" file, then go to the ones that are imported by that file, and so on.
197
- Please note that the code should be fully functional. No placeholders.
198
-
199
- Follow a language and framework appropriate best practice file naming convention.
200
- 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.
201
- Ensure to implement all code, if you are unsure, write a plausible implementation.
202
- Include module dependency or package manager dependency definition file.
203
- Before you finish, double check that all parts of the architecture is present in the files.
204
-
205
- When you are done, write finish with "this concludes a fully working implementation".
206
-
207
- Useful to know:
208
- Almost always put different classes in different files.
209
- Always use the programming language the user asks for.
210
- For Python, you always create an appropriate requirements.txt file.
211
- For NodeJS, you always create an appropriate package.json file.
212
- Always add a comment briefly describing the purpose of the function definition.
213
- Add comments explaining very complex bits of logic.
214
- Always follow the best practices for the requested languages for folder/file structure and how to package the project.
215
-
216
-
217
- Python toolbelt preferences:
218
- - pytest
219
- - dataclasses
220
-
221
-
222
- ================================ Human Message =================================
223
-
224
- Request: duckdbのサンプルの作成
225
- sample.csvを作成して その内容にCRUD
226
-
227
- ================================== Ai Message ==================================
228
-
229
- Here is a Python implementation using DuckDB and Pytest for testing.
230
-
231
- **requirements.txt**
232
- ```
233
- duckdb
234
- pytest
235
- ```
236
-
237
- **sample.csv**
238
- ```
239
- id,name,age
240
- 1,Alice,25
241
- 2,Bob,30
242
- 3,Charlie,35
243
- ```
244
-
245
- **duckdb_manager.py**
246
- ```
247
- import duckdb
248
-
249
- class DuckDBManager:
250
- def __init__(self, db_path):
251
- self.db_path = db_path
252
- self.conn = duckdb.connect(database=self.db_path)
253
-
254
- def create_table(self, table_name, columns):
255
- query = f"CREATE TABLE IF NOT EXISTS {table_name} ({', '.join(columns)})"
256
- self.conn.execute(query)
257
-
258
- def insert(self, table_name, values):
259
- query = f"INSERT INTO {table_name} VALUES ({', '.join(['?' for _ in values])})"
260
- self.conn.execute(query, values)
261
-
262
- def select(self, table_name, columns):
263
- query = f"SELECT {', '.join(columns)} FROM {table_name}"
264
- return self.conn.execute(query).fetchall()
265
-
266
- def update(self, table_name, set_columns, where_clause):
267
- query = f"UPDATE {table_name} SET {', '.join([f'{col} = ?' for col in set_columns])} WHERE {where_clause}"
268
- self.conn.execute(query, [set_columns[col] for col in set_columns])
269
-
270
- def delete(self, table_name, where_clause):
271
- query = f"DELETE FROM {table_name} WHERE {where_clause}"
272
- self.conn.execute(query)
273
-
274
- def close(self):
275
- self.conn.close()
276
- ```
277
-
278
- **crud_operations.py**
279
- ```
280
- from duckdb_manager import DuckDBManager
281
-
282
- class CRUDOperations:
283
- def __init__(self, db_path):
284
- self.db_manager = DuckDBManager(db_path)
285
-
286
- def create(self, table_name, columns, values):
287
- self.db_manager.create_table(table_name, columns)
288
- self.db_manager.insert(table_name, values)
289
-
290
- def read(self, table_name, columns):
291
- return self.db_manager.select(table_name, columns)
292
-
293
- def update(self, table_name, set_columns, where_clause):
294
- self.db_manager.update(table_name, set_columns, where_clause)
295
-
296
- def delete(self, table_name, where_clause):
297
- self.db_manager.delete(table_name, where_clause)
298
- ```
299
-
300
- **test_crud_operations.py**
301
- ```
302
- import pytest
303
- from crud_operations import CRUDOperations
304
-
305
- @pytest.fixture
306
- def crud_operations():
307
- return CRUDOperations('sample.db')
308
-
309
- def test_create(crud_operations):
310
- crud_operations.create('users', ['id', 'name', 'age'], [1, 'Alice', 25])
311
- assert crud_operations.read('users', ['id', 'name', 'age']) == [(1, 'Alice', 25)]
312
-
313
- def test_read(crud_operations):
314
- crud_operations.create('users', ['id', 'name', 'age'], [1, 'Alice', 25])
315
- assert crud_operations.read('users', ['id', 'name', 'age']) == [(1, 'Alice', 25)]
316
-
317
- def test_update(crud_operations):
318
- crud_operations.create('users', ['id', 'name', 'age'], [1, 'Alice', 25])
319
- crud_operations.update('users', {'name': 'Bob'}, 'id = 1')
320
- assert crud_operations.read('users', ['id', 'name', 'age']) == [(1, 'Bob', 25)]
321
-
322
- def test_delete(crud_operations):
323
- crud_operations.create('users', ['id', 'name', 'age'], [1, 'Alice', 25])
324
- crud_operations.delete('users', 'id = 1')
325
- assert crud_operations.read('users', ['id', 'name', 'age']) == []
326
- ```
327
-
328
- This concludes a fully working implementation.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
projects/example/.gpteng/memory/logs/gen_entrypoint_chat.txt DELETED
@@ -1,248 +0,0 @@
1
-
2
- 2024-06-01T15:39:54.592348
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: requirements.txt
24
- 1 duckdb
25
- 2 pytest
26
-
27
- File: sample.csv
28
- 1 id,name,age
29
- 2 1,Alice,25
30
- 3 2,Bob,30
31
- 4 3,Charlie,35
32
-
33
- File: duckdb_manager.py
34
- 1 import duckdb
35
- 2
36
- 3 class DuckDBManager:
37
- 4 def __init__(self, db_path):
38
- 5 self.db_path = db_path
39
- 6 self.conn = duckdb.connect(database=self.db_path)
40
- 7
41
- 8 def create_table(self, table_name, columns):
42
- 9 query = f"CREATE TABLE IF NOT EXISTS {table_name} ({', '.join(columns)})"
43
- 10 self.conn.execute(query)
44
- 11
45
- 12 def insert(self, table_name, values):
46
- 13 query = f"INSERT INTO {table_name} VALUES ({', '.join(['?' for _ in values])})"
47
- 14 self.conn.execute(query, values)
48
- 15
49
- 16 def select(self, table_name, columns):
50
- 17 query = f"SELECT {', '.join(columns)} FROM {table_name}"
51
- 18 return self.conn.execute(query).fetchall()
52
- 19
53
- 20 def update(self, table_name, set_column, set_value, where_column, where_value):
54
- 21 query = f"UPDATE {table_name} SET {set_column} = ? WHERE {where_column} = ?"
55
- 22 self.conn.execute(query, (set_value, where_value))
56
- 23
57
- 24 def delete(self, table_name, where_column, where_value):
58
- 25 query = f"DELETE FROM {table_name} WHERE {where_column} = ?"
59
- 26 self.conn.execute(query, (where_value,))
60
- 27
61
- 28 def close(self):
62
- 29 self.conn.close()
63
-
64
- File: crud_operations.py
65
- 1 from duckdb_manager import DuckDBManager
66
- 2
67
- 3 class CRUDOperations:
68
- 4 def __init__(self, db_path):
69
- 5 self.db_manager = DuckDBManager(db_path)
70
- 6
71
- 7 def create(self, table_name, columns, values):
72
- 8 self.db_manager.create_table(table_name, columns)
73
- 9 self.db_manager.insert(table_name, values)
74
- 10
75
- 11 def read(self, table_name, columns):
76
- 12 return self.db_manager.select(table_name, columns)
77
- 13
78
- 14 def update(self, table_name, set_column, set_value, where_column, where_value):
79
- 15 self.db_manager.update(table_name, set_column, set_value, where_column, where_value)
80
- 16
81
- 17 def delete(self, table_name, where_column, where_value):
82
- 18 self.db_manager.delete(table_name, where_column, where_value)
83
-
84
- File: test_crud_operations.py
85
- 1 import pytest
86
- 2 from crud_operations import CRUDOperations
87
- 3
88
- 4 @pytest.fixture
89
- 5 def crud_operations():
90
- 6 return CRUDOperations('sample.db')
91
- 7
92
- 8 def test_create(crud_operations):
93
- 9 crud_operations.create('users', ['id INTEGER', 'name TEXT', 'age INTEGER'], (1, 'Alice', 25))
94
- 10 assert crud_operations.read('users', ['*']) == [(1, 'Alice', 25)]
95
- 11
96
- 12 def test_read(crud_operations):
97
- 13 crud_operations.create('users', ['id INTEGER', 'name TEXT', 'age INTEGER'], (1, 'Alice', 25))
98
- 14 assert crud_operations.read('users', ['*']) == [(1, 'Alice', 25)]
99
- 15
100
- 16 def test_update(crud_operations):
101
- 17 crud_operations.create('users', ['id INTEGER', 'name TEXT', 'age INTEGER'], (1, 'Alice', 25))
102
- 18 crud_operations.update('users', 'age', 30, 'id', 1)
103
- 19 assert crud_operations.read('users', ['*']) == [(1, 'Alice', 30)]
104
- 20
105
- 21 def test_delete(crud_operations):
106
- 22 crud_operations.create('users', ['id INTEGER', 'name TEXT', 'age INTEGER'], (1, 'Alice', 25))
107
- 23 crud_operations.delete('users', 'id', 1)
108
- 24 assert crud_operations.read('users', ['*']) == []
109
-
110
- ```
111
-
112
- ================================== Ai Message ==================================
113
-
114
- Here is the Unix script that installs dependencies and runs the codebase:
115
- ```
116
- #!/bin/bash
117
-
118
- # Install dependencies
119
- pip install -r requirements.txt
120
-
121
- # Run tests
122
- pytest test_crud_operations.py
123
- ```
124
- Save this script to a file (e.g. `run_codebase.sh`), make it executable with `chmod +x run_codebase.sh`, and then run it with `./run_codebase.sh`.
125
-
126
- 2024-06-01T15:40:49.435311
127
- ================================ System Message ================================
128
-
129
- You will get information about a codebase that is currently on disk in the current folder.
130
- The user will ask you to write a script that runs the code in a specific way.
131
- You will answer with code blocks that include all the necessary terminal commands.
132
- Do not install globally. Do not use sudo.
133
- Do not explain the code, just give the commands.
134
- Do not use placeholders, use example values (like . for a folder argument) if necessary.
135
-
136
-
137
- ================================ Human Message =================================
138
-
139
-
140
- Make a unix script that
141
- a) installs dependencies
142
- b) runs all necessary parts of the codebase (in parallel if necessary)
143
-
144
- Information about the codebase:
145
-
146
- ```
147
- File: requirements.txt
148
- 1 duckdb
149
- 2 pytest
150
-
151
- File: sample.csv
152
- 1 id,name,age
153
- 2 1,Alice,25
154
- 3 2,Bob,30
155
- 4 3,Charlie,35
156
-
157
- File: duckdb_manager.py
158
- 1 import duckdb
159
- 2
160
- 3 class DuckDBManager:
161
- 4 def __init__(self, db_path):
162
- 5 self.db_path = db_path
163
- 6 self.conn = duckdb.connect(database=self.db_path)
164
- 7
165
- 8 def create_table(self, table_name, columns):
166
- 9 query = f"CREATE TABLE IF NOT EXISTS {table_name} ({', '.join(columns)})"
167
- 10 self.conn.execute(query)
168
- 11
169
- 12 def insert(self, table_name, values):
170
- 13 query = f"INSERT INTO {table_name} VALUES ({', '.join(['?' for _ in values])})"
171
- 14 self.conn.execute(query, values)
172
- 15
173
- 16 def select(self, table_name, columns):
174
- 17 query = f"SELECT {', '.join(columns)} FROM {table_name}"
175
- 18 return self.conn.execute(query).fetchall()
176
- 19
177
- 20 def update(self, table_name, set_columns, where_clause):
178
- 21 query = f"UPDATE {table_name} SET {', '.join([f'{col} = ?' for col in set_columns])} WHERE {where_clause}"
179
- 22 self.conn.execute(query, [set_columns[col] for col in set_columns])
180
- 23
181
- 24 def delete(self, table_name, where_clause):
182
- 25 query = f"DELETE FROM {table_name} WHERE {where_clause}"
183
- 26 self.conn.execute(query)
184
- 27
185
- 28 def close(self):
186
- 29 self.conn.close()
187
-
188
- File: crud_operations.py
189
- 1 from duckdb_manager import DuckDBManager
190
- 2
191
- 3 class CRUDOperations:
192
- 4 def __init__(self, db_path):
193
- 5 self.db_manager = DuckDBManager(db_path)
194
- 6
195
- 7 def create(self, table_name, columns, values):
196
- 8 self.db_manager.create_table(table_name, columns)
197
- 9 self.db_manager.insert(table_name, values)
198
- 10
199
- 11 def read(self, table_name, columns):
200
- 12 return self.db_manager.select(table_name, columns)
201
- 13
202
- 14 def update(self, table_name, set_columns, where_clause):
203
- 15 self.db_manager.update(table_name, set_columns, where_clause)
204
- 16
205
- 17 def delete(self, table_name, where_clause):
206
- 18 self.db_manager.delete(table_name, where_clause)
207
-
208
- File: test_crud_operations.py
209
- 1 import pytest
210
- 2 from crud_operations import CRUDOperations
211
- 3
212
- 4 @pytest.fixture
213
- 5 def crud_operations():
214
- 6 return CRUDOperations('sample.db')
215
- 7
216
- 8 def test_create(crud_operations):
217
- 9 crud_operations.create('users', ['id', 'name', 'age'], [1, 'Alice', 25])
218
- 10 assert crud_operations.read('users', ['id', 'name', 'age']) == [(1, 'Alice', 25)]
219
- 11
220
- 12 def test_read(crud_operations):
221
- 13 crud_operations.create('users', ['id', 'name', 'age'], [1, 'Alice', 25])
222
- 14 assert crud_operations.read('users', ['id', 'name', 'age']) == [(1, 'Alice', 25)]
223
- 15
224
- 16 def test_update(crud_operations):
225
- 17 crud_operations.create('users', ['id', 'name', 'age'], [1, 'Alice', 25])
226
- 18 crud_operations.update('users', {'name': 'Bob'}, 'id = 1')
227
- 19 assert crud_operations.read('users', ['id', 'name', 'age']) == [(1, 'Bob', 25)]
228
- 20
229
- 21 def test_delete(crud_operations):
230
- 22 crud_operations.create('users', ['id', 'name', 'age'], [1, 'Alice', 25])
231
- 23 crud_operations.delete('users', 'id = 1')
232
- 24 assert crud_operations.read('users', ['id', 'name', 'age']) == []
233
-
234
- ```
235
-
236
- ================================== Ai Message ==================================
237
-
238
- Here is the Unix script that installs dependencies and runs the codebase:
239
- ```
240
- #!/bin/bash
241
-
242
- # Install dependencies
243
- pip install -r requirements.txt
244
-
245
- # Run tests in parallel
246
- pytest -n 4 test_crud_operations.py
247
- ```
248
- Note: The `-n 4` flag tells pytest to run tests in parallel using 4 workers. You can adjust this number based on your system's resources.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
projects/example/crud_operations.py DELETED
@@ -1,19 +0,0 @@
1
- from duckdb_manager import DuckDBManager
2
-
3
-
4
- class CRUDOperations:
5
- def __init__(self, db_path):
6
- self.db_manager = DuckDBManager(db_path)
7
-
8
- def create(self, table_name, columns, values):
9
- self.db_manager.create_table(table_name, columns)
10
- self.db_manager.insert(table_name, values)
11
-
12
- def read(self, table_name, columns):
13
- return self.db_manager.select(table_name, columns)
14
-
15
- def update(self, table_name, set_columns, where_clause):
16
- self.db_manager.update(table_name, set_columns, where_clause)
17
-
18
- def delete(self, table_name, where_clause):
19
- self.db_manager.delete(table_name, where_clause)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
projects/example/duckdb_manager.py DELETED
@@ -1,30 +0,0 @@
1
- import duckdb
2
-
3
-
4
- class DuckDBManager:
5
- def __init__(self, db_path):
6
- self.db_path = db_path
7
- self.conn = duckdb.connect(database=self.db_path)
8
-
9
- def create_table(self, table_name, columns):
10
- query = f"CREATE TABLE IF NOT EXISTS {table_name} ({', '.join(columns)})"
11
- self.conn.execute(query)
12
-
13
- def insert(self, table_name, values):
14
- query = f"INSERT INTO {table_name} VALUES ({', '.join(['?' for _ in values])})"
15
- self.conn.execute(query, values)
16
-
17
- def select(self, table_name, columns):
18
- query = f"SELECT {', '.join(columns)} FROM {table_name}"
19
- return self.conn.execute(query).fetchall()
20
-
21
- def update(self, table_name, set_columns, where_clause):
22
- query = f"UPDATE {table_name} SET {', '.join([f'{col} = ?' for col in set_columns])} WHERE {where_clause}"
23
- self.conn.execute(query, [set_columns[col] for col in set_columns])
24
-
25
- def delete(self, table_name, where_clause):
26
- query = f"DELETE FROM {table_name} WHERE {where_clause}"
27
- self.conn.execute(query)
28
-
29
- def close(self):
30
- self.conn.close()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
projects/example/prompt DELETED
@@ -1,2 +0,0 @@
1
- duckdbのサンプルの作成
2
- sample.csvを作成して その内容にCRUD
 
 
 
projects/example/requirements.txt DELETED
@@ -1,2 +0,0 @@
1
- duckdb
2
- pytest
 
 
 
projects/example/run.sh DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Install dependencies
4
- pip install -r requirements.txt
5
-
6
- # Run tests in parallel
7
- pytest -n 4 test_crud_operations.py
 
 
 
 
 
 
 
 
projects/example/sample.csv DELETED
@@ -1,4 +0,0 @@
1
- id,name,age
2
- 1,Alice,25
3
- 2,Bob,30
4
- 3,Charlie,35
 
 
 
 
 
projects/example/test_crud_operations.py DELETED
@@ -1,29 +0,0 @@
1
- import pytest
2
- from crud_operations import CRUDOperations
3
-
4
-
5
- @pytest.fixture
6
- def crud_operations():
7
- return CRUDOperations("sample.db")
8
-
9
-
10
- def test_create(crud_operations):
11
- crud_operations.create("users", ["id", "name", "age"], [1, "Alice", 25])
12
- assert crud_operations.read("users", ["id", "name", "age"]) == [(1, "Alice", 25)]
13
-
14
-
15
- def test_read(crud_operations):
16
- crud_operations.create("users", ["id", "name", "age"], [1, "Alice", 25])
17
- assert crud_operations.read("users", ["id", "name", "age"]) == [(1, "Alice", 25)]
18
-
19
-
20
- def test_update(crud_operations):
21
- crud_operations.create("users", ["id", "name", "age"], [1, "Alice", 25])
22
- crud_operations.update("users", {"name": "Bob"}, "id = 1")
23
- assert crud_operations.read("users", ["id", "name", "age"]) == [(1, "Bob", 25)]
24
-
25
-
26
- def test_delete(crud_operations):
27
- crud_operations.create("users", ["id", "name", "age"], [1, "Alice", 25])
28
- crud_operations.delete("users", "id = 1")
29
- assert crud_operations.read("users", ["id", "name", "age"]) == []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{staticfiles → tests}/database.db RENAMED
File without changes
{staticfiles → tests}/teams.db RENAMED
File without changes
{staticfiles → tests}/test.py RENAMED
File without changes
{staticfiles → tests}/testgroq.py RENAMED
File without changes