github.com/dolthub/go-mysql-server@v0.18.0/SUPPORTED_CLIENTS.md (about)

     1  # Supported clients
     2  
     3  These are the clients we actively test against to check that they are
     4  compatible with go-mysql-server. Other clients may also work, but we
     5  don't check on every build if we remain compatible with them.
     6  
     7  - Python
     8    - [pymysql](#pymysql)
     9    - [mysql-connector](#python-mysql-connector)
    10    - [sqlalchemy](#python-sqlalchemy)
    11  - Ruby
    12    - [ruby-mysql](#ruby-mysql)
    13  - [PHP](#php)
    14  - Node.js
    15    - [mysqljs/mysql](#mysqljs)
    16  - .NET Core
    17    - [MysqlConnector](#mysqlconnector)
    18  - Java/JVM
    19    - [mariadb-java-client](#mariadb-java-client)
    20  - Go
    21    - [go-mysql-driver/mysql](#go-sql-drivermysql)
    22  - C
    23    - [mysql-connector-c](#mysql-connector-c)
    24  - Grafana
    25  - Tableau Desktop
    26  
    27  ## Example client usage
    28  
    29  ### pymysql
    30  
    31  ```python
    32  import pymysql.cursors
    33  
    34  connection = pymysql.connect(host='127.0.0.1',
    35                               user='root',
    36                               password='',
    37                               db='mydb',
    38                               cursorclass=pymysql.cursors.DictCursor)
    39  
    40  try:
    41      with connection.cursor() as cursor:
    42          sql = "SELECT * FROM mytable LIMIT 1"
    43          cursor.execute(sql)
    44          rows = cursor.fetchall()
    45  
    46          # use rows
    47  finally:
    48      connection.close()
    49  ```
    50  
    51  ### Python mysql-connector
    52  
    53  ```python
    54  import mysql.connector
    55  
    56  connection = mysql.connector.connect(host='127.0.0.1',
    57                                  user='root',
    58                                  passwd='',
    59                                  port=3306,
    60                                  database='mydb')
    61  
    62  try:
    63      cursor = connection.cursor()
    64      sql = "SELECT * FROM mytable LIMIT 1"
    65      cursor.execute(sql)
    66      rows = cursor.fetchall()
    67  
    68      # use rows
    69  finally:
    70      connection.close()
    71  ```
    72  
    73  ### Python sqlalchemy
    74  
    75  ```python
    76  import pandas as pd
    77  import sqlalchemy
    78  
    79  engine = sqlalchemy.create_engine('mysql+pymysql://root:@127.0.0.1:3306/mydb')
    80  with engine.connect() as conn:
    81       repo_df = pd.read_sql_table("mytable", con=conn)
    82       for table_name in repo_df.to_dict():
    83          print(table_name)
    84  ```
    85  
    86  ### ruby-mysql
    87  
    88  ```ruby
    89  require "mysql"
    90  
    91  conn = Mysql::new("127.0.0.1", "root", "", "mydb")
    92  resp = conn.query "SELECT * FROM mytable LIMIT 1"
    93  
    94  # use resp
    95  
    96  conn.close()
    97  ```
    98  
    99  ### php
   100  
   101  ```php
   102  try {
   103      $conn = new PDO("mysql:host=127.0.0.1:3306;dbname=mydb", "root", "");
   104      $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
   105  
   106      $stmt = $conn->query('SELECT * FROM mytable LIMIT 1');
   107      $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
   108  
   109      // use result
   110  } catch (PDOException $e) {
   111      // handle error
   112  }
   113  ```
   114  
   115  ### mysqljs
   116  
   117  ```js
   118  import mysql from 'mysql';
   119  
   120  const connection = mysql.createConnection({
   121      host: '127.0.0.1',
   122      port: 3306,
   123      user: 'root',
   124      password: '',
   125      database: 'mydb'
   126  });
   127  connection.connect();
   128  
   129  const query = 'SELECT * FROM mytable LIMIT 1';
   130  connection.query(query, function (error, results, _) {
   131      if (error) throw error;
   132  
   133      // use results
   134  });
   135  
   136  connection.end();
   137  ```
   138  
   139  ### MysqlConnector
   140  
   141  ```csharp
   142  using MySql.Data.MySqlClient;
   143  using System.Threading.Tasks;
   144  
   145  namespace something
   146  {
   147      public class Something
   148      {
   149          public async Task DoQuery()
   150          {
   151              var connectionString = "server=127.0.0.1;user id=root;password=;port=3306;database=mydb;";
   152  
   153              using (var conn = new MySqlConnection(connectionString))
   154              {
   155                  await conn.OpenAsync();
   156  
   157                  var sql = "SELECT * FROM mytable LIMIT 1";
   158  
   159                  using (var cmd = new MySqlCommand(sql, conn))
   160                  using (var reader = await cmd.ExecuteReaderAsync())
   161                  while (await reader.ReadAsync()) {
   162                      // use reader
   163                  }
   164              }
   165          }
   166      }
   167  }
   168  ```
   169  
   170  ### mariadb-java-client
   171  
   172  ```java
   173  package org.testing.mariadbjavaclient;
   174  
   175  import java.sql.*;
   176  
   177  class Main {
   178      public static void main(String[] args) {
   179          String dbUrl = "jdbc:mariadb://127.0.0.1:3306/mydb?user=root&password=";
   180          String query = "SELECT * FROM mytable LIMIT 1";
   181  
   182          try (Connection connection = DriverManager.getConnection(dbUrl)) {
   183              try (PreparedStatement stmt = connection.prepareStatement(query)) {
   184                  try (ResultSet rs = stmt.executeQuery()) {
   185                      while (rs.next()) {
   186                          // use rs
   187                      }
   188                  }
   189              }
   190          } catch (SQLException e) {
   191              // handle failure
   192          }
   193      }
   194  }
   195  ```
   196  
   197  ### go-sql-driver/mysql
   198  
   199  ```go
   200  package main
   201  
   202  import (
   203  	"database/sql"
   204  
   205  	_ "github.com/go-sql-driver/mysql"
   206  )
   207  
   208  func main() {
   209      db, err := sql.Open("mysql", "root:@tcp(127.0.0.1:3306)/mydb")
   210  	if err != nil {
   211  		// handle error
   212  	}
   213  
   214  	rows, err := db.Query("SELECT * FROM mytable LIMIT 1")
   215  	if err != nil {
   216  		// handle error
   217      }
   218  
   219      // use rows
   220  }
   221  ```
   222  
   223  ### mysql-connector-c
   224  
   225  ```c
   226  #include <my_global.h>
   227  #include <mysql.h>
   228  
   229  void finish_with_error(MYSQL *con)
   230  {
   231      fprintf(stderr, "%s\n", mysql_error(con));
   232      mysql_close(con);
   233      exit(1);
   234  }
   235  
   236  int main(int argc, char **argv)
   237  {
   238      MYSQL *con = NULL;
   239      MYSQL_RES *result = NULL;
   240      int num_fields = 0;
   241      MYSQL_ROW row;
   242  
   243      printf("MySQL client version: %s\n", mysql_get_client_info());
   244  
   245      con = mysql_init(NULL);
   246      if (con == NULL) {
   247          finish_with_error(con);
   248      }
   249  
   250      if (mysql_real_connect(con, "127.0.0.1", "root", "", "mydb", 3306, NULL, 0) == NULL) {
   251          finish_with_error(con);
   252      }
   253  
   254      if (mysql_query(con, "SELECT name, email, phone_numbers FROM mytable")) {
   255          finish_with_error(con);
   256      }
   257  
   258      result = mysql_store_result(con);
   259      if (result == NULL) {
   260          finish_with_error(con);
   261      }
   262  
   263      num_fields = mysql_num_fields(result);
   264      while ((row = mysql_fetch_row(result))) {
   265          for(int i = 0; i < num_fields; i++) {
   266              printf("%s ", row[i] ? row[i] : "NULL");
   267          }
   268          printf("\n");
   269      }
   270  
   271      mysql_free_result(result);
   272      mysql_close(con);
   273  
   274      return 0;
   275  }
   276  ```