sqlgen

package module
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 6 Imported by: 0

README

SQLGen

Go Reference

SQLGen is a command-line tool written in Go that helps you generate SQL queries efficiently.

Features

  • Generate basic SQL queries for PostgreSQL and MySQL

Installation

To install SQLGen, you need to have Go installed on your machine. Then, you can use the following command to install SQLGen:

# postgres
go install github.com/miyataka/sqlgen/cmd/psqlgen@latest

# mysql
go install github.com/miyataka/sqlgen/cmd/mysqlgen@latest

Usage

After installing SQLGen, you can use it from the command line. Here are some examples of how to use SQLGen:

# Generate SQL queries for PostgreSQL
psqlgen --dsn= "postgres://user:password@localhost:5432/dbname"

# Generate SQL queries for MySQL
mysqlgen --dsn= "user:password@tcp(localhost:3306)/dbname"

When using with sqlc, you can generate SQL queries from the schema file:

# Generate SQL queries for PostgreSQL with comments for sqlc
psqlgen --dsn= "postgres://user:password@localhost:5432/dbname" --sqlc

# Generate SQL queries for MySQL with comments for sqlc
mysqlgen --dsn= "user:password@tcp(localhost:3306)/dbname" --sqlc

Contributing

We welcome contributions to SQLGen! If you have any ideas, suggestions, or bug reports, please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTableName

func GetTableName(sql string) (string, error)

GetTableName extracts the table name from an INSERT SQL statement.

func Singularize

func Singularize(str string) string

func SnakeToPascal

func SnakeToPascal(input string) string

SnakeToPascal converts a snake_case string to PascalCase using golang.org/x/text/cases

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL