55## Installation
66
77```
8- $ go install github.com/ngrash/sqlcup/cmd/sqlcup@v0.3 .0
8+ $ go install github.com/ngrash/sqlcup/cmd/sqlcup@v0.4 .0
99```
1010
1111## Usage
1414$ sqlcup -help
1515sqlcup - generate SQL statements for sqlc (https://sqlc.dev)
1616
17- Synopsis:
18- sqlcup [options] <name> <column> ...
19-
20- Description:
21- sqlcup prints SQL statements to stdout. The <name> argument given to sqlcup
22- must be of the form <singular>/<plural> where <singular> is the name of the
23- Go struct and <plural> is the name of the database table.
24- sqlcup capitalizes those names where required.
25-
26- Each <column> arguments given to sqlcup defines a database column and must
27- be of the form <name>:<type>[:<constraint>]. <name>, <type> and the
28- optional <constraint> are used to generate a CREATE TABLE statement.
29- In addition, <name> also appears in the SQL queries. sqlcup never
30- capitalizes those names.
31-
32- If any part of a <column> contains a space, it may be necessary to add
33- quotes or escape those spaces, depending on the user's shell.
34-
35- Example:
36- sqlcup author/authors "id:INTEGER:PRIMARY KEY" "name:text:NOT NULL" bio:text
37- sqlcup --order-by name user/users "id:INTEGER:PRIMARY KEY" name:text
38-
39- Options:
17+ Synopsis:
18+ sqlcup [options] <name> <column> ...
19+
20+ Description:
21+ sqlcup prints SQL statements to stdout. The <name> argument given to sqlcup
22+ must be of the form <singular>/<plural> where <singular> is the name of the
23+ Go struct and <plural> is the name of the database table.
24+ sqlcup capitalizes those names where required.
25+
26+ Each column argument given to sqlcup defines a database column and must
27+ be either a <plain-column> or a <smart-column>:
28+
29+ A <plain-column> must be of the form <name>:<type>[:<constraint>]. <name>,
30+ <type> and the optional <constraint> are used to generate a CREATE TABLE
31+ statement. In addition, <name> also appears in SQL queries. sqlcup never
32+ capitalizes those names. To use <tag> you need to define a <smart-column>.
33+
34+ A <smart-column> is a shortcut for common column definitions. It must be of
35+ the form <name>@<tag>@<tag>...
36+
37+ A <tag> adds either a data type or a constraint to a <smart-column>.
38+
39+ @id
40+ Make this column the primary key. Omitting column type and <name>
41+ for an @id column creates an INTEGER PRIMARY KEY named 'id'.
42+
43+ @text, @int, @float, @double, @datetime, @blob
44+ Set the column type.
45+
46+ @unique
47+ Add a UNIQUE constraint.
48+
49+ @null
50+ Omit NOT NULL constraint.
51+
52+ If any part of a <column> contains a space, it may be necessary to add
53+ quotes or escape those spaces, depending on the user's shell.
54+
55+ Example:
56+ sqlcup author/authors "id:INTEGER:PRIMARY KEY" "name:text:NOT NULL" bio:text
57+ sqlcup --order-by name user/users "id:INTEGER:PRIMARY KEY" name:text
58+ sqlcup author/authors @id name@text@unique bio@text@null
59+
60+ Options:
4061 -id-column string
4162 Name of the column that identifies a row (default "id")
4263 -no-exists-clause
@@ -47,6 +68,7 @@ Options:
4768 Limit output to 'schema' or 'queries'
4869 -order-by string
4970 Include ORDER BY in 'SELECT *' statement
71+
5072```
5173
5274## Example
0 commit comments