![]() Refer to the above manual to implement account.sql as follows: - name: CreateAccount :one INSERT INTO accounts ( PHONY: postgres createdb dropdb sqlc Copy the code SQL create database table model file (*.sql) version: "1" packages: - name: "db" path: "./db/sqlc" queries: "./db/query/" schema: "./db/postgresql/" engine: "postgresql" emit_prepared_queries: false emit_interface: false emit_exact_table_names: true emit_empty_slices: false emit_json_tags: true json_tags_case_style: "camel" Copy the code Perfect the Makefile postgres:ĭocker run -name postgres12 -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=xxxxxx -d postgres:12-alpineĭocker exec -it postgres12 dropdb simple_bank Initialize SQLC: SQLC init generates the sqlC. Then click the corresponding system to downloadĪfter the download is unpacked, add environment variables and run SQLC version to see the version:.When you generate code, you know about SQL errors.Field mapping is by way of query text, and the structure is tagged Īddress: reference docs.It runs almost as fast as the standard library and is very easy to use.When the traffic is high, the operation is slow.ĭocument address: /jmoiron/sql.Easy to use, built-in encapsulation to achieve CRUD operations, advanced object relational mapping. ![]() ![]() Some parameter errors in function calls need to be flagged at run time ĭocument address: gorm.io/docs/ query.Corresponding mapping fields need to be defined.It runs very fast and performs well when writing code.Using the standard library database tools, compare the original operation, this approach advantages and disadvantages: Generate CRUD and compare db_SQL \gorm\ SQLXĬRUD stands for "add, delete, modify, and check" operation. Open TablePlus to view the newly created simple_bank database: The contents of the Makefile and make command are as follows: Run the following command to create a database:Įxit and drop the database using the dropdb command, as shown below:Įxecute the command to create the database when running the container:ĭocker exec -it postgres12 createdb -username=root -owner=root simple_bankĮxecute the command to drop the database while running the container:ĭocker exec -it postgres12 dropdb simple_bank Write a Makefile Golang-migrate Github address: /golang-migr.Import SQL file and run SQL command to create three tables: View postgres container logs: Docker logs Postgres12 tablepuls In addition: interested in learning network programming, recommend a training camp: hands-on combat network programming, can use the invitation code: AqCJeLyy preferential.Įnter the console of the running container Postgres environment: Run: docker run -name postgres12 -p 5432:5432 -e POSTGRES_USER=root -e POSTGRES_PASSWORD=xxxxxx -d postgres:12-alpine Postgres warehouse address: /_/postgres.The back-end Go Install and use Docker + Postgres + TablePlus Install postgres
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |