Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ajm188/sqlx-gen

codegen for sqlx structs from CREATE TABLE statements
https://github.com/ajm188/sqlx-gen

Last synced: 4 days ago
JSON representation

codegen for sqlx structs from CREATE TABLE statements

Awesome Lists containing this project

README

        

# sqlx-gen
codegen for sqlx structs from CREATE TABLE statements

## Example Usage

```
❯ go build -o main.bin main.go
❯ ./main.bin -schema create_commerce_schema.sql
2021/07/28 21:30:04 [warn] select * from corder is not a CreateTable (type: *sqlparser.Select), skipping ...
// Code generated by sqlx-gen. DO NOT EDIT.

package models

type Product struct {
Sku []byte `json:"sku" db:"sku"`
Description []byte `json:"description" db:"description"`
Price int64 `json:"price" db:"price"`
}

type Customer struct {
CustomerId int64 `json:"customer_id" db:"customer_id"`
Email []byte `json:"email" db:"email"`
IsActive bool `json:"is_active" db:"is_active"`
}

type Corder struct {
OrderId int64 `json:"order_id" db:"order_id"`
CustomerId int64 `json:"customer_id" db:"customer_id"`
Sku []byte `json:"sku" db:"sku"`
Price int64 `json:"price" db:"price"`
}
```