MySQL Connector Go

授权协议 BSD
开发语言 Google Go
所属分类 数据库相关、 数据库驱动程序
软件类型 开源软件
地区 不详
投 递 者 邴俊友
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

MySQL Connector Go 是 Google Go 编程语言连接 MySQL 数据库的驱动程序。

示例代码:

package main

import (
        "mysql";
        "fmt";
)

// define mysql information
const (
        hostname        = "localhost";
        username        = "gotest";
        password        = "gotest";
        database        = "gotest";
)

func main() {
        var query string;

        // connect to the database using the information defined above
        db := mysql.Connect(hostname, username, password, database);
        db.SelectDb("gotest");

        // run an update query
        query = "UPDATE `gotest` SET `testfield` = 'Update something'";
        fmt.Println("Executing query: ", query);
        db.Query(query);

        // if the query was successful, view some information
        fmt.Println("Affected rows: ", db.AffectedRows, "InsertId: ", db.InsertId, "\n");

        // run an insert query
        query = "INSERT INTO `gotest` SET `testfield` = 'Insert something', `testfield2` = 12345.123, `testfield3` = NOW()";
        db.Query(query);
        fmt.Println("Executing query: ", query);

        // if the query was successful, view some information
        fmt.Println("Affected rows:", db.AffectedRows, "InsertId:", db.InsertId, "\n");

        query = "SELECT * FROM `gotest`";
        db.Query(query);
        fmt.Println("Executing query: ", query);
        fmt.Println("Num rows: ", db.NumRows());

        for {
                row := db.FetchRow();
                if row == nil {
                        break
                }
                fmt.Printf("(%T) %d => (%T) %s, (%T) %f, (%T) %+v\n", row[0], row[0], row[1], row[1], row[2], row[2], row[3], row[3]);
        }

        // close the connection
        db.Close();
}

  • Hey there, I'm writing an app in C that requires MySQL interaction, so I downloaded the Connector/C archive from the official website, and it contains bin, lib and include folders, but I don't know wh

  • Hey there, I'm writing an app in C that requires MySQL interaction, so I downloaded the Connector/C archive from the official website, and it contains bin, lib and include folders, but I don't know wh

  • 1.java连接MySQL(JDBC) package Abc; import java.sql.*; public class DBConnection{ public static void main(String args[]){ String url="jdbc:mysql://localhost:3306/login"; String strUser="root"; String str

  • 往MySQL中存储图片 1 介绍 在设计到数据库的开发中,难免要将图片或音频文件插入到数据库中的情况。一般来说,我们可以同过插入图片文件相应的存储位置,而不是文件本身,来避免直接向数据库里插入的麻烦。但有些时候,向MySQL中插入图片更加容易管理。那么在MySQL中该怎么存储呢? 参考资料[1]中有个相当清晰的例子,不过是基于MySQL图形界面的查询工具Query Brower的,你的机子上没有安

  • 转载自:https://www.douyacun.com/ go连接mysql为什么需要 import _ "github.com/go-sql-driver/mysql" go中import _的作用只执行引入包的init函数,那么go-sql-driver/mysql 的init函数又做了什么,在database/sql 中的drivers map[string]driver.Driver注册

  • I have installed Python 3.7 64-bit on my 64-bit OS. I have also Installed mysql-installer-community-8.0.15.0 plus I installed MySQL connector using this code python -m pip install mysql-connector and

相关阅读

相关文章

相关问答

相关文档