-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotes.txt
More file actions
executable file
·105 lines (61 loc) · 4.86 KB
/
notes.txt
File metadata and controls
executable file
·105 lines (61 loc) · 4.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
structs
postrgres db
sqlx functions to add returve data
* sql strings
** adding data should be simmple (just keep track of if cols are nessisary)
** returving data will need filters. this may be harder (tell ai in proces layse it can use joining and fillterign functions withch will then be defined in the data layer)
*** will need inner + outer join, and where clouse, this call all be generated
*** may wan enum for where clouse (== vs <= ...) and join (inner vs outer vs left )
*** use string typing to check if bounds of where are ok
*** make new structs (rows) based on the retreving sqlx string (cols will be from Select suchs as * for all, and constrains will be placed on struct based on where clouse)
*** constraints should only be placed on struct if where is not looking for exact match on unequ col but returning
* json the user sends could be subset of struct filds that need to be added to db if some fileds need to be calulated
** you will need input_ struct and db struct (witch you have)
seperate funcitons that interact with db fron funcitons that return data to user
## test for ai
ai can you ...
make a pg db to represent farmers and gardeners, a farmer is someone who needs food to feed their lifestock like grass clipings
and a gardernder is someworn who gardens and has things like grass clipings.
garderners
* type of biomass
* location
* has_compost
* id
farmerd
* needs_compost
* location
* id
can you make rust structs from that
can you make sqlx functions to retruve and add the structs to the db
can you make axum endpoints for each sqlx function
auth
use this for asking ai to make sql
can you write some sql to make a postgreSQL database to
tables should be defined with CREATE TABLE IF NOT EXISTS
only use these datatypes:
BOOL, "CHAR", SMALLINT, SMALLSERIAL, INT2, INT, SERIAL, INT4, BIGINT, BIGSERIAL, INT8, REAL, FLOAT4, DOUBLE PRECISION, FLOAT8, VARCHAR, CHAR(N), TEXT, NAME, CITEXT, BYTEA, VOID, INTERVAL, INT8RANGE, INT4RANGE, TSRANGE, TSTZRANGE, DATERANGE, TIMESTAMPTZ, TIMESTAMPTZ, TIMESTAMP, DATE, TIME, TIMETZ, UUID, INET, CIDR, INET, CIDR, INET, CIDR, INET, CIDR, MACADDR, BIT, VARBIT, JSON, JSONB, JSON, JSONB, JSON, JSONB
use unequ where nesisary (inline not at the bottom of the table)
use gen_random_uuid when using uuids.
dont use numeric, insted use int or float or somting
dont use table names like `public."user"`
all tables should have a uuid that auto increments
docker
docker run -d --name my-postgres -p 1111:5432 -e POSTGRES_USER=dbuser -e POSTGRES_PASSWORD=p -e POSTGRES_DB=work postgres
Here is how you should write postgres SQL code to define a database. tables should be defined with CREATE TABLE IF NOT EXISTS. only use these datatypes: BOOL, "CHAR", SMALLINT, SMALLSERIAL, INT2, INT, SERIAL, INT4, BIGINT, BIGSERIAL, INT8, REAL, FLOAT4, DOUBLE PRECISION, FLOAT8, VARCHAR, CHAR(N), TEXT, NAME, CITEXT, BYTEA, VOID, INTERVAL, INT8RANGE, INT4RANGE, TSRANGE, TSTZRANGE, DATERANGE, TIMESTAMPTZ, TIMESTAMPTZ, TIMESTAMP, DATE, TIME, TIMETZ, UUID, INET, CIDR, INET, CIDR, INET, CIDR, INET, CIDR, MACADDR, BIT, VARBIT, JSON, JSONB, JSON, JSONB, JSON, JSONB. use unequ where nesisary (inline not at the bottom of the table). use gen_random_uuid when using uuids. dont use numeric, insted use int or float or somting. dont use table names like `public."user"`. all tables should have a uuid that auto increments. Dont use any comments. You need to write some sql to define a postgreSQL database to store runs for users. a user should have an email, name, and favoret running shoe. a run should have a user, and started at date/time, and distance and a duration. each run should have exactly one user, but a user can have many runs. Dont output anything but the sql code.
for example if i say "define a postgresSQL database that stores work sessions for users. each users has a start time, duration, break time, and a user. each user has an email and a name. each work session has exactly one user and each user can have many work sessions." then you should output ```
CREATE DATABASE mydatabase;
CREATE TABLE IF NOT EXISTS users (
user_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(255)
);
CREATE TABLE IF NOT EXISTS work_sessions (
work_session_id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES users(user_id),
start_time TIMESTAMPTZ NOT NULL,
duration_seconds INT NOT NULL,
break_duration_seconds INT NOT NULL DEFAULT 0
);
```
now, use postgres SQL to define a database that tracks cups of coffee a user has drank. eash user should have an email and a name. the coffee table should have, type of coffee, the date it was drank, and the user that drank it.
now, use postgres SQL to define a database that tracks the runs of users. a user has an email and a name. a run has a start date/time, a duration, and a user. each run has exactly one user but a user can have many runs.