Giter Club home page Giter Club logo

gen's Introduction

gen's People

Contributors

180909 avatar aizk avatar boogiig avatar calvinchengx avatar crossworth avatar d-tsuji avatar danysz avatar dkarakis avatar flyingtimeice avatar geek981108 avatar ghstahl avatar ipsusila avatar jcolson avatar josgilmo avatar leopku avatar liugehao avatar shelmingsong avatar smallnest avatar telemac avatar w00j00ng avatar wainwrightmark avatar walterwanderley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gen's Issues

numeric field in postgresql

Hi, I want to generate model from postgresql table below

image

however, when I generate it using gen, the numeric field somehow gone (not included when generate)

image

am I missing something?

Thanks

Can't connect to mssql; don't find information how to use this tool

Hi,

i tried to get structs of an existing mssql database, but it fails with an error

gen --sqltype "sqlserver" --connstr "server=localhost;user id=sa;password={xxx}" --database xxx  --json --gorm

=> 2019/05/24 14:09:39 unknown db driver *mssql.Driver

same with

gen --sqltype "mssql" --connstr "server=localhost;user id=sa;password={xxx}" --database xxx  --json --gorm

different with "asdasd" instead of "mssql". Is this a bug, or do i use it wrong?

If table name is order will case gen fail

if table name is 'order', the struct generated wiill be empty:

package model

import (
	"database/sql"
	"time"

	"github.com/guregu/null"
)

var (
	_ = time.Second
	_ = sql.LevelDefault
	_ = null.Bool{}
)

type Order struct {
}

// TableName sets the insert table name for this struct type
func (o *Order) TableName() string {
	return "order"
}

gen param isgen --connstr 'xxxx' --table order --gorm --json

when I change table to order2, bug not show again

Support for uuid and CHARACTER varying[] in Postgres database

  • for DDL like this:
create table companies
(
    id                  uuid                default public.uuid_generate_v4() not null   constraint clients_pkey
    tags                character varying[] default '{}'::character varying[],
    deleted_by_id       uuid,
    created_by_id       uuid,
);
  • gen outputs errors like:
table: companies unable to generate struct field: id type: UUID error: unknown sql type: uuid
table: companies unable to generate struct field: tags type: _VARCHAR error: unknown sql type: _varchar
table: companies unable to generate struct field: deleted_by_id type: UUID error: unknown sql type: uuid
table: companies unable to generate struct field: created_by_id type: UUID error: unknown sql type: uuid

Issues

  • It seems like gen doesn't support the uuid type
  • It seems like gen doesn't support the CHARACTER Varying[] type

Sqlite

I am having a hard time seeing how other databases than mysql are supported for inspection. I cannot get sqlite database to work with the command line tool, and the code has mysql driver hardcoded.

datetime2 support

In MS SQL , I have some columns of data type datetime2 which generates errors like DATETIME2 error: unknown sql type: datetime2.

I suppose it can be fixed in the mapping.json or is there any option to use it ?

doesn't generate model properties

All generated models have no properties generated

$ go version
go version go1.12.7 darwin/amd64
gen --connstr "root:root@tcp(127.0.0.1:3306)/abc?&parseTime=True" --database abc  --json --gorm --guregu --rest
package model

import (
        "database/sql"
        "time"
        "github.com/guregu/null"
)

var (
        _ = time.Second
        _ = sql.LevelDefault
        _ = null.Bool{}
)

type Transaction struct {
}

// TableName sets the insert table name for this struct type
func (t *Transaction) TableName() string {
        return "transaction"
}

generated struct has no fields

`package model

import (
"database/sql"
"time"
"github.com/guregu/null"
)

var (
_ = time.Second
_ = sql.LevelDefault
_ = null.Bool{}
)

type UserAliinfo struct {
}

// TableName sets the insert table name for this struct type
func (u *UserAliinfo) TableName() string {
return "user_aliinfo"
}
`

model_base.go.tmpl not found error

Hello,

I wanted to create structs from a mysql database for gorm (no other features) like this - from a db hosted on localhost:

gen --sqltype=mysql \
   	--connstr "$DB_USER:$DB_PASS@/$DB_NAME" \
   	--database $DB_NAME  \
   	--json \
    --out ./models \
   	--gorm \
   	--overwrite

what I am getting is this:

Error loading template model_base.go.tmpl not found

am I missing something?

If I copy the file from the gen repo into a local folder and pass the templateDir parameter, I do get results, but all accompanied by this error:

Error in loading model template, error: template: model:20: function "IsNullable" not defined

mysql cann't generate go model struct

in dbmeta/meta.go GenerateStruct function line101, when the tablename is user , the sql string is SELECT * FROM user LIMIT 0 . that is a error sql query string.

Gorm Optional Struct tags

Does this package support gorm optional structs tags such as Size, PRIMARY_KEY, AUTO_INCREMENT?
https://gorm.io/docs/models.html#Supported-Struct-tags

type Batch struct {
	ID          int            `gorm:"column:id;primary_key" json:"id"`
	Title       string         `gorm:"column:title" json:"title"`
	Description sql.NullString `gorm:"column:description" json:"description"`
	UrlsCount   int            `gorm:"column:urls_count" json:"urls_count"`
	CreatedAt   time.Time      `gorm:"column:created_at" json:"created_at"`
	UpdatedAt   time.Time      `gorm:"column:updated_at" json:"updated_at"`
}

above struct was created with following command but no optional struct tags
gen --connstr "USER:PASSWORD@tcp(127.0.0.1:3306)/dbname" --database dbname --table batches --gorm --json

if you leave --protobuf out of opts, but have --db, it will generate protobuff models tags instead of db:

below does NOT generate sqlx tags in models, but DOES generate protobuf tags

gen -v \
    --sqltype=mysql \
   	--connstr "`cat db_conn_file.txt`" \
   	--json \
   	--out server \
   	--generate-dao \
   	--overwrite \
   	--database trictrac \
    --model=models \
	--module=trictr.ac/server \
	--templateDir=template-gen \
  	--db \
    --guregu

ex:

type AccountMember struct {
	//[ 0] member_id                                      varchar(36)          null: false  primary: true   auto: false  col: varchar         len: 36      default: []
	MemberID string `json:"member_id" protobuf:"string,0,opt,name=member_id"`
	//[ 1] email_address                                  text(65535)          null: true   primary: false  auto: false  col: text            len: 65535   default: [NULL]
	EmailAddress null.String `json:"email_address" protobuf:"string,1,opt,name=email_address"`
	//[ 2] first_name                                     text(65535)          null: true   primary: false  auto: false  col: text            len: 65535   default: [NULL]
	FirstName null.String `json:"first_name" protobuf:"string,2,opt,name=first_name"`
	//[ 3] last_name                                      text(65535)          null: true   primary: false  auto: false  col: text            len: 65535   default: [NULL]
	LastName null.String `json:"last_name" protobuf:"string,3,opt,name=last_name"`
	//[ 4] joined_timestamp                               timestamp            null: false  primary: false  auto: false  col: timestamp       len: -1      default: [current_timestamp()]
	JoinedTimestamp time.Time `json:"joined_timestamp" protobuf:"uint64,4,opt,name=joined_timestamp"`
	//[ 5] role                                           text(65535)          null: false  primary: false  auto: false  col: text            len: 65535   default: []
	Role string `json:"role" protobuf:"string,5,opt,name=role"`
	//[ 6] hashauth                                       text(65535)          null: false  primary: false  auto: false  col: text            len: 65535   default: []
	Hashauth string `json:"hashauth" protobuf:"string,6,opt,name=hashauth"`
}

below DOES generates sqlx tags in models (as well as protobuf)

gen -v \
    --sqltype=mysql \
   	--connstr "`cat db_conn_file.txt`" \
   	--json \
   	--out server \
   	--generate-dao \
   	--overwrite \
   	--database trictrac \
    --model=models \
	--module=trictr.ac/server \
	--templateDir=template-gen \
  	--db \
	--protobuf \
    --guregu

ex:

type AccountMember struct {
	//[ 0] member_id                                      varchar(36)          null: false  primary: true   auto: false  col: varchar         len: 36      default: []
	MemberID string `json:"member_id" db:"member_id" protobuf:"string,0,opt,name=member_id"`
	//[ 1] email_address                                  text(65535)          null: true   primary: false  auto: false  col: text            len: 65535   default: [NULL]
	EmailAddress null.String `json:"email_address" db:"email_address" protobuf:"string,1,opt,name=email_address"`
	//[ 2] first_name                                     text(65535)          null: true   primary: false  auto: false  col: text            len: 65535   default: [NULL]
	FirstName null.String `json:"first_name" db:"first_name" protobuf:"string,2,opt,name=first_name"`
	//[ 3] last_name                                      text(65535)          null: true   primary: false  auto: false  col: text            len: 65535   default: [NULL]
	LastName null.String `json:"last_name" db:"last_name" protobuf:"string,3,opt,name=last_name"`
	//[ 4] joined_timestamp                               timestamp            null: false  primary: false  auto: false  col: timestamp       len: -1      default: [current_timestamp()]
	JoinedTimestamp time.Time `json:"joined_timestamp" db:"joined_timestamp" protobuf:"uint64,4,opt,name=joined_timestamp"`
	//[ 5] role                                           text(65535)          null: false  primary: false  auto: false  col: text            len: 65535   default: []
	Role string `json:"role" db:"role" protobuf:"string,5,opt,name=role"`
	//[ 6] hashauth                                       text(65535)          null: false  primary: false  auto: false  col: text            len: 65535   default: []
	Hashauth string `json:"hashauth" db:"hashauth" protobuf:"string,6,opt,name=hashauth"`
}

this is at commit -> 0c7236f

How to iniitialize data null.String

Hi,

I have struct with null.String data type (generated through smallnest/gen), however I got the error

./user_related_unit_test.go:92:82: cannot use "abc" (type string) as type null.String in field value

when I tried to initialize it:

UserCredentialObject := model.UserCredential{UserID: 1, Sequence: 1, AesPwdOld: "abc", AesPwdNew: null, PinBlockOld: "1234", PinBlockNew: "5678"}

[Bug report]sslmode issue caused by connstr in "regen" part of Makefile

gen version

0.9.7 (06/09/2020)

OS

macOS 10.14.6

Shell

zsh 5.3 (x86_64-apple-darwin18.0)

Database

~ ❯❯❯ brew info postgresql
postgresql: stable 12.3 (bottled), HEAD

Description

  1. Run gen --sqltype=postgres --connstr=..., it works.

  2. Run make regen with default connstr param,

    --connstr=host=127.0.0.1 \
    port=5432 \
    user=myname \
    password=mypass \
    dbname=mydb \
    sslmode=disable \

it occurred with

Error pinging database: pq: SSL is not enabled on the server

Error in initializing db pq: SSL is not enabled on the server
make: *** [regen] Error 1
  1. change --connstr in Makefile to below and run make regen, it should works well.
    --connstr="host=127.0.0.1 port=5432 user=myname password=mypass dbname=mydb sslmode=disable connect_timeout=10000" \

But --connstr in Makefile had been changed to default format like step 2.

Maybe reason

I'm using zsh with zprezto.
Maybe it only broken in zsh? I don't know.

Postgres and SQLite driver support for sql.ColumnType.Nullable()

Hi,

I see you are using my 'schema' package! This is just a quick note to inform you of its limitations...

It works very well with some drivers, and not so well with others: sadly, not all drivers provide full support for methods on sql.ColumnType

Drivers with good/working .Nullable() support:

  • MS SQL - github.com/denisenkom/go-mssqldb
  • MySQL - github.com/go-sql-driver/mysql
  • Oracle - github.com/go-goracle/goracle

But I have not yet found a driver with support for .Nullable() on Postgres nor SQLite.

For further details see the report(s) at https://github.com/jimsmart/drivercaps — it's quite a can of worms.

I think the best solution is for the upstream drivers to add this missing support? But I have not yet filed any issues upstream, nor had time to look at any of the drivers' code.

HTH

Connect to PostgresSQL

I can't connect to a Postgres db, line 67 of main.go has static code for connection type.
var db, err = sql.Open("mysql", *sqlConnStr)
Suggest adding an execution parameter for specifying database type.

Support for timestamptz type in postgres

Getting this error when using tables (e.g. "mytable") that uses the timestamptz type in postgresql database:-

table: mytable unable to generate struct field: created type: TIMESTAMPTZ error: unknown sql type: timestamptz

希望能支持xorm库

gorm库虽然stars很高,但个人觉得使用起来没有xorm方便,也没sqlx性能好,希望能支持xorm库

can not support unsigned int

sql 语句

CREATE TABLE `user`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `user_id` int(0) UNSIGNED NOT NULL COMMENT '用户id',
  `role` int(0) NOT NULL DEFAULT 0 COMMENT '在此平台角色0用户1代购2个体商户3推广员4总代',
  `vip_level` int(0) NULL DEFAULT NULL COMMENT 'vip等级',
  `union_id` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '微信唯一索引',
  `open_id` varchar(45) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '微信openid',
  `nick_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '微信昵称',
  `avatar_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT '微信头像',
  `gender` tinyint(0) NOT NULL COMMENT '性别,0男生1女生',
  `country` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '所在国家',
  `province` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '省份',
  `city` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '城市',
  `language` varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NULL DEFAULT NULL COMMENT '语种',
  `bind_user_id` int(0) NULL DEFAULT NULL COMMENT '绑定人员',
  `phone_number` bigint(0) NULL DEFAULT NULL COMMENT '手机号码',
  `due_time` datetime(0) NULL DEFAULT NULL COMMENT '到期时间',
  `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime(0) NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '修改时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE INDEX `openid_UNIQUE`(`open_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = DYNAMIC;

生成的model

type User struct {
	ID          int64       `gorm:"AUTO_INCREMENT;column:id;type:BIGINT;primary_key" json:"id"`                     //[ 0] id                                             bigint               null: false  primary: true   auto: true   col: bigint          len: -1      default: []
	UserID      int         `gorm:"column:user_id;type:INT;" json:"user_id"`                                        //[ 1] user_id                                        int                  null: false  primary: false  auto: false  col: int             len: -1      default: []
	Role        int         `gorm:"column:role;type:INT;default:0;" json:"role"`                                    //[ 2] role                                           int                  null: false  primary: false  auto: false  col: int             len: -1      default: [0]
	VipLevel    null.Int    `gorm:"column:vip_level;type:INT;" json:"vip_level"`                                    //[ 3] vip_level                                      int                  null: true   primary: false  auto: false  col: int             len: -1      default: []
	UnionID     string      `gorm:"column:union_id;type:VARCHAR;size:45;" json:"union_id"`                          //[ 4] union_id                                       varchar(45)          null: false  primary: false  auto: false  col: varchar         len: 45      default: []
	OpenID      string      `gorm:"column:open_id;type:VARCHAR;size:45;" json:"open_id"`                            //[ 5] open_id                                        varchar(45)          null: false  primary: false  auto: false  col: varchar         len: 45      default: []
	NickName    null.String `gorm:"column:nick_name;type:VARCHAR;size:100;" json:"nick_name"`                       //[ 6] nick_name                                      varchar(100)         null: true   primary: false  auto: false  col: varchar         len: 100     default: []
	AvatarURL   string      `gorm:"column:avatar_url;type:VARCHAR;size:255;" json:"avatar_url"`                     //[ 7] avatar_url                                     varchar(255)         null: false  primary: false  auto: false  col: varchar         len: 255     default: []
	Gender      int         `gorm:"column:gender;type:TINYINT;" json:"gender"`                                      //[ 8] gender                                         tinyint              null: false  primary: false  auto: false  col: tinyint         len: -1      default: []
	Country     null.String `gorm:"column:country;type:VARCHAR;size:100;" json:"country"`                           //[ 9] country                                        varchar(100)         null: true   primary: false  auto: false  col: varchar         len: 100     default: []
	Province    null.String `gorm:"column:province;type:VARCHAR;size:100;" json:"province"`                         //[10] province                                       varchar(100)         null: true   primary: false  auto: false  col: varchar         len: 100     default: []
	City        null.String `gorm:"column:city;type:VARCHAR;size:100;" json:"city"`                                 //[11] city                                           varchar(100)         null: true   primary: false  auto: false  col: varchar         len: 100     default: []
	Language    null.String `gorm:"column:language;type:VARCHAR;size:100;" json:"language"`                         //[12] language                                       varchar(100)         null: true   primary: false  auto: false  col: varchar         len: 100     default: []
	BindUserID  null.Int    `gorm:"column:bind_user_id;type:INT;" json:"bind_user_id"`                              //[13] bind_user_id                                   int                  null: true   primary: false  auto: false  col: int             len: -1      default: []
	PhoneNumber null.Int    `gorm:"column:phone_number;type:BIGINT;" json:"phone_number"`                           //[14] phone_number                                   bigint               null: true   primary: false  auto: false  col: bigint          len: -1      default: []
	DueTime     null.Time   `gorm:"column:due_time;type:DATETIME;" json:"due_time"`                                 //[15] due_time                                       datetime             null: true   primary: false  auto: false  col: datetime        len: -1      default: []
	CreateTime  null.Time   `gorm:"column:create_time;type:DATETIME;" json:"create_time"`                           //[16] create_time                                    datetime             null: true   primary: false  auto: false  col: datetime        len: -1      default: []
	UpdateTime  null.Time   `gorm:"column:update_time;type:DATETIME;default:CURRENT_TIMESTAMP;" json:"update_time"` //[17] update_time                                    datetime             null: true   primary: false  auto: false  col: datetime        len: -1      default: [CURRENT_TIMESTAMP]

}

可以看到 从mysql生成golang结构体时,不支持unsigned int, mysql定义的字段类型是unsigned int,但是generated
出来的结构体是int, 如果使用mapping.json配置的话,估计也不能解决.

postgresql 连接使用方法

gen --sqltype=postgres  --connstr "host=127.0.0.1 port=5432 user=$PGUSER dbname=$PGDATABASE password=$PGPASSWORD sslmode=disable  connect_timeout=10000" --database $PGDATABASE  --json --gorm --guregu --rest

不能识别mysql 的 unsigned decimal数据类型

表创建语句

DROP TABLE IF EXISTS `test_db`;
CREATE TABLE `test_db`  (
  `id` int(0) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `created_at` datetime(0) NOT NULL COMMENT '创建时间',
  `updated_at` datetime(0) NOT NULL COMMENT '更新时间',
  `deleted_at` datetime(0) NULL DEFAULT NULL COMMENT '删除时间',
  `type_id` bigint(0) UNSIGNED NOT NULL DEFAULT 0,
  `name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `age` int(0) NULL DEFAULT NULL,
  `avatar_url` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `passwd` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `created` datetime(0) NULL DEFAULT NULL,
  `updated` datetime(0) NULL DEFAULT NULL,
  `gender` enum('one','two') CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL,
  `birthday` datetime(0) NULL DEFAULT NULL,
  `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `detial` json NULL,
  `price` decimal(10, 2) UNSIGNED NULL DEFAULT NULL,
  PRIMARY KEY (`id`, `type_id`) USING BTREE,
  UNIQUE INDEX `uix_test_db_email`(`email`) USING BTREE,
  INDEX `idx_test_db_deleted_at`(`deleted_at`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = DYNAMIC;

SET FOREIGN_KEY_CHECKS = 1;

其中price,生成model时会报错 table: test_db unable to generate struct field: price type: udecimal error: unknown sql type: udecimal.

[Feature Request]table prefix support

All my tables had same prefix like xxx_, for example:

xxx_users
xxx_posts
xxx_tokens

The generated codes like model, dao, routes all have xxx included, like XxxUser , GetAllXxxUser and /xxxuser, /xxxuser/:argId.

I wanna request a new feature like adding something like a param named prefix and auto stripping the prefix when generating codes. The ideal model, dao, routes look likes following User, GetAllUser, /user and /user/:argId

why the struct don't have member?

gen -c 'mitra:shopee123!@tcp(10.12.77.233)/apc_report_db?&parseTime=True' --database apc_report_db -t dp_order_report_tab --package dbreport --json --gorm --guregu

package model

import (
"database/sql"
"time"

"github.com/guregu/null"

)

var (
_ = time.Second
_ = sql.LevelDefault
_ = null.Bool{}
)

type DpOrderReportTab struct {
}

// TableName sets the insert table name for this struct type
func (d *DpOrderReportTab) TableName() string {
return "dp_order_report_tab"
}

Not working now?

Run as $ gen -v --connstr "root:roooooot@/test" --package test --database test --table label --json --gorm

Nothing hanppend.

ENV:
mysql Ver 8.0.18 for macos10.14 on x86_64
go version go1.13.1 darwin/amd64

model can not generate varchar size in mysql

table create statement

DROP TABLE IF EXISTS `express_company`;
CREATE TABLE `express_company`  (
  `id` int(0) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '主键',
  `express_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '快递公司名称',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = DYNAMIC;

version:0.9.12

when I use this table to create model,generate code is like:

// ExpressCompany struct is a row record of the express_company table in the daigou database
type ExpressCompany struct {
	//[ 0] id                                             uint                 null: false  primary: true   isArray: false  auto: true   col: uint            len: -1      default: []
	ID uint32 `gorm:"primary_key;AUTO_INCREMENT;column:id;type:uint;" json:"id"`
	//[ 1] express_name                                   varchar              null: false  primary: false  isArray: false  auto: false  col: varchar         len: 0       default: []
	ExpressName string `gorm:"column:express_name;type:varchar;" json:"express_name"`
}

image

How can I connect to a sqlite3 database file?

I am reviewing the command line options but do not understand how to connect to a sqlite3 database. I have a file.db and the table name is account. I want to create output suitable for a gorm model.

What command line options should I use?

option to not use MustExecContext in dao

mustexec causes panic in key violations ... when normally you would want to catch those errors yourself.

an option to not use mustexec by default in dao's would be stellar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.