{"id":42794,"library":"gg-mysql-connector","title":"GGMySQLConnector","description":"gg-mysql-connector (v1.0.247) is a TypeScript-first MySQL toolkit that provides schema definition, migration, TypeScript and Zod artifact generation, and typed querying. It treats schema definitions as a single source of truth, allowing developers to define tables, columns, indexes, and foreign keys in code, then push changes to MySQL. Features include automated migration (table creation, column modification, index updates) and reverse-engineering existing databases to generate types and Zod schemas. Updated frequently with 247+ releases; requires mysql2. Differentiates from Prisma/TypeORM by being lighter-weight and more focused on schema-first workflows without an ORM layer.","status":"active","version":"1.0.247","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","typescript"],"install":[{"cmd":"npm install gg-mysql-connector","lang":"bash","label":"npm"},{"cmd":"yarn add gg-mysql-connector","lang":"bash","label":"yarn"},{"cmd":"pnpm add gg-mysql-connector","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Underlying MySQL driver used for all database connections and queries.","package":"mysql2","optional":false},{"reason":"Required for generateZodSchemaFromMySQL utility to produce Zod schemas.","package":"zod","optional":true}],"imports":[{"note":"ESM-only; no CommonJS module provided.","wrong":"const GGMySQLConnector = require('gg-mysql-connector')","symbol":"GGMySQLConnector","correct":"import { GGMySQLConnector } from 'gg-mysql-connector'"},{"note":"Named export, not default.","wrong":"import MySQLSchemaManager from 'gg-mysql-connector'","symbol":"MySQLSchemaManager","correct":"import { MySQLSchemaManager } from 'gg-mysql-connector'"},{"note":"MyModel is a type (Array of ColumnContent), not a class constructor. Use type import to avoid runtime bundle inclusion.","wrong":"import { MyModel } from 'gg-mysql-connector'","symbol":"MyModel","correct":"import { type MyModel } from 'gg-mysql-connector'"},{"note":"Function can be renamed, but no default export.","wrong":"import { classifyDbError as classify } from 'gg-mysql-connector'","symbol":"classifyDbError","correct":"import { classifyDbError } from 'gg-mysql-connector'"}],"quickstart":{"code":"import { GGMySQLConnector, MySQLSchemaManager, MyModel, type DatabaseConfigInterface } from 'gg-mysql-connector';\n\nconst dbInfo: DatabaseConfigInterface = {\n  host: process.env.DB_HOST ?? 'localhost',\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASSWORD ?? '',\n  database: process.env.DB_NAME ?? 'test',\n  port: 3306,\n  dateStrings: true,\n  connectionLimit: 3,\n  waitForConnections: true,\n  connectTimeout: 10000,\n  queueLimit: 0,\n  enableKeepAlive: true,\n  keepAliveInitialDelay: 1000,\n};\n\nconst db = new GGMySQLConnector(dbInfo);\n\nconst model: MyModel[] = [\n  {\n    tableName: 'users',\n    columns: [\n      { COLUMN_NAME: 'id', DATA_TYPE: 'int', AUTO_INCREMENT: true },\n      { COLUMN_NAME: 'name', DATA_TYPE: 'varchar(255)' },\n    ],\n  },\n];\n\nconst migrator = new MySQLSchemaManager(dbInfo, model);\nmigrator.isShowProgress = true;\nawait migrator.init();\nawait migrator.pushSchemaToDatabase();","lang":"typescript","description":"Connects to MySQL, defines a user table schema, and pushes it to the database using migration manager."},"warnings":[{"fix":"Ensure all numeric pool options are valid numbers. For connectionLimit, the default is 10 if invalid.","message":"Invalid numeric pool options (e.g., connectionLimit set to a non-number) silently fall back to defaults; no error thrown.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always set boolean options to a literal true or false, not a string or number.","message":"Boolean options (e.g., waitForConnections) are only respected when the value is exactly true or false; other values are ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use pushViews (plural) if available, or accept the typo.","message":"The pushVie method name is misspelled (should be pushView?); maintained for backward compatibility.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use MyModel as a type annotation for arrays of column definitions, e.g., const model: MyModel[] = [...]","message":"MyModel is a type alias for an array of ColumnContent, not a class. Attempting 'new MyModel()' causes TypeScript compilation error.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install zod: npm install zod","message":"The generateZodSchemaFromMySQL function requires Zod to be installed as a peer dependency; missing it causes runtime error.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'247':79 'allow':37 'artifact':22 'autom':56 'chang':51 'code':48 'column':42,60 'connector':5 'creation':59 'databas':69 'defin':40 'definit':17,30 'develop':38 'differenti':83 'engin':67 'exist':68 'featur':54 'first':11,97 'focus':93 'foreign':45 'frequent':77 'generat':23,71 'gg':3 'gg-mysql-connector':2 'ggmysqlconnector':1 'includ':55 'index':43,62 'javascript':103 'key':46 'layer':102 'lighter':89 'lighter-weight':88 'migrat':18,57 'modif':61 'mysql':4,12,53 'mysql2':82 'orm':101 'prisma/typeorm':85 'provid':15 'push':50 'queri':26 'releas':80 'requir':81 'revers':66 'reverse-engin':65 'schema':16,29,75,96 'schema-first':95 'singl':33 'sourc':34 'tabl':41,58 'toolkit':13 'treat':28 'truth':36 'type':25,72 'typescript':10,19,104 'typescript-first':9 'updat':63,76 'v1.0.247':6 'weight':90 'without':99 'workflow':98 'zod':21,74","created_at":"2026-06-05T16:56:41.675454+00:00","updated_at":"2026-06-05T16:56:41.675454+00:00","problems":[{"fix":"npm install mysql2","cause":"Missing peer dependency mysql2.","error":"Error: Cannot find module 'mysql2'"},{"fix":"Change to import { GGMySQLConnector } from 'gg-mysql-connector' and ensure your project uses ESM (e.g., 'type': 'module' in package.json).","cause":"Using CommonJS require on an ESM-only package.","error":"TypeError: GGMySQLConnector is not a constructor"},{"fix":"Remove 'new MyModel()' and use MyModel only for type annotations.","cause":"Trying to instantiate MyModel as a class, but it's a type.","error":"TypeError: MyModel is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":null,"npm":"gg-mysql-connector","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}