Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 953042f

Browse files
author
kuba--
committed
Update examples
Signed-off-by: kuba-- <[email protected]>
1 parent de21348 commit 953042f

File tree

11 files changed

+52
-52
lines changed

11 files changed

+52
-52
lines changed

SUPPORTED_CLIENTS.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ These are the clients we actively test against to check are compatible with go-m
2828
import pymysql.cursors
2929

3030
connection = pymysql.connect(host='127.0.0.1',
31-
user='user',
32-
password='pass',
33-
db='db',
31+
user='root',
32+
password='',
33+
db='gitbase',
3434
cursorclass=pymysql.cursors.DictCursor)
3535

3636
try:
3737
with connection.cursor() as cursor:
38-
sql = "SELECT foo FROM bar"
38+
sql = "SELECT * FROM commit_files LIMIT 1"
3939
cursor.execute(sql)
4040
rows = cursor.fetchall()
4141

@@ -50,14 +50,14 @@ finally:
5050
import mysql.connector
5151

5252
connection = mysql.connector.connect(host='127.0.0.1',
53-
user='user',
54-
passwd='pass',
53+
user='root',
54+
passwd='',
5555
port=3306,
56-
database='dbname')
56+
database='gitbase')
5757

5858
try:
5959
cursor = connection.cursor()
60-
sql = "SELECT foo FROM bar"
60+
sql = "SELECT * FROM commit_files LIMIT 1"
6161
cursor.execute(sql)
6262
rows = cursor.fetchall()
6363

@@ -72,9 +72,9 @@ finally:
7272
import pandas as pd
7373
import sqlalchemy
7474

75-
engine = sqlalchemy.create_engine('mysql+pymysql://user:pass@127.0.0.1:3306/dbname')
75+
engine = sqlalchemy.create_engine('mysql+pymysql://root:@127.0.0.1:3306/gitbase')
7676
with engine.connect() as conn:
77-
repo_df = pd.read_sql_table("mytable", con=conn)
77+
repo_df = pd.read_sql_table("commit_files", con=conn)
7878
for table_name in repo_df.to_dict():
7979
print(table_name)
8080
```
@@ -84,8 +84,8 @@ with engine.connect() as conn:
8484
```ruby
8585
require "mysql"
8686

87-
conn = Mysql::new("127.0.0.1", "user", "pass", "dbname")
88-
resp = conn.query "SELECT foo FROM bar"
87+
conn = Mysql::new("127.0.0.1", "root", "", "gitbase")
88+
resp = conn.query "SELECT * FROM commit_files LIMIT 1"
8989

9090
# use resp
9191

@@ -96,10 +96,10 @@ conn.close()
9696

9797
```php
9898
try {
99-
$conn = new PDO("mysql:host=127.0.0.1:3306;dbname=dbname", "user", "pass");
99+
$conn = new PDO("mysql:host=127.0.0.1:3306;dbname=gitbase", "root", "");
100100
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
101101

102-
$stmt = $conn->query('SELECT foo FROM bar');
102+
$stmt = $conn->query('SELECT * FROM commit_files LIMIT 1');
103103
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
104104

105105
// use result
@@ -116,13 +116,13 @@ import mysql from 'mysql';
116116
const connection = mysql.createConnection({
117117
host: '127.0.0.1',
118118
port: 3306,
119-
user: 'user',
120-
password: 'pass',
121-
database: 'dbname'
119+
user: 'root',
120+
password: '',
121+
database: 'gitbase'
122122
});
123123
connection.connect();
124124

125-
const query = 'SELECT foo FROM bar';
125+
const query = 'SELECT * FROM commit_files LIMIT 1';
126126
connection.query(query, function (error, results, _) {
127127
if (error) throw error;
128128

@@ -144,13 +144,13 @@ namespace something
144144
{
145145
public async Task DoQuery()
146146
{
147-
var connectionString = "server=127.0.0.1;user id=user;password=pass;port=3306;database=dbname;";
147+
var connectionString = "server=127.0.0.1;user id=root;password=;port=3306;database=gitbase;";
148148

149149
using (var conn = new MySqlConnection(connectionString))
150150
{
151151
await conn.OpenAsync();
152152

153-
var sql = "SELECT foo FROM bar";
153+
var sql = "SELECT * FROM commit_files LIMIT 1";
154154

155155
using (var cmd = new MySqlCommand(sql, conn))
156156
using (var reader = await cmd.ExecuteReaderAsync())
@@ -172,8 +172,8 @@ import java.sql.*;
172172

173173
class Main {
174174
public static void main(String[] args) {
175-
String dbUrl = "jdbc:mariadb://127.0.0.1:3306/dbname?user=user&password=pass";
176-
String query = "SELECT foo FROM bar";
175+
String dbUrl = "jdbc:mariadb://127.0.0.1:3306/gitbase?user=root&password=";
176+
String query = "SELECT * FROM commit_files LIMIT 1";
177177

178178
try (Connection connection = DriverManager.getConnection(dbUrl)) {
179179
try (PreparedStatement stmt = connection.prepareStatement(query)) {
@@ -202,16 +202,16 @@ import (
202202
)
203203

204204
func main() {
205-
db, err := sql.Open("mysql", "user:pass@tcp(127.0.0.1:3306)/test")
205+
db, err := sql.Open("mysql", "root:@tcp(127.0.0.1:3306)/gitbase")
206206
if err != nil {
207207
// handle error
208208
}
209209

210-
rows, err := db.Query("SELECT foo FROM bar")
210+
rows, err := db.Query("SELECT * FROM commit_files LIMIT 1")
211211
if err != nil {
212212
// handle error
213213
}
214214

215215
// use rows
216216
}
217-
```
217+
```

_example/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func main() {
3131
config := server.Config{
3232
Protocol: "tcp",
3333
Address: "localhost:3306",
34-
Auth: auth.NewNativeSingle("user", "pass", auth.AllPermissions),
34+
Auth: auth.NewNativeSingle("root", "", auth.AllPermissions),
3535
}
3636

3737
s, err := server.NewDefaultServer(config, engine)
@@ -44,7 +44,7 @@ func main() {
4444

4545
func createTestDatabase() *mem.Database {
4646
const (
47-
dbName = "test"
47+
dbName = "gitbase"
4848
tableName = "mytable"
4949
)
5050

_integration/dotnet/MySQLTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ public class MySQLTest
1010
[TestMethod]
1111
public async Task TestCanConnect()
1212
{
13-
var connectionString = "server=127.0.0.1;user id=user;password=pass;port=3306;database=db;";
13+
var connectionString = "server=127.0.0.1;user id=root;password=;port=3306;database=gitbase;";
1414
var expected = new string[][]{
1515
new string[]{"Evil Bob", "[email protected]"},
1616
new string[]{"Jane Doe", "[email protected]"},
1717
new string[]{"John Doe", "[email protected]"},
1818
new string[]{"John Doe", "[email protected]"},
1919
};
20-
20+
2121
using (var conn = new MySqlConnection(connectionString))
2222
{
2323
await conn.OpenAsync();

_integration/go/mysql_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
_ "github.com/go-sql-driver/mysql"
99
)
1010

11-
const connectionString = "user:pass@tcp(127.0.0.1:3306)/test"
11+
const connectionString = "root:@tcp(127.0.0.1:3306)/gitbase"
1212

1313
func TestMySQL(t *testing.T) {
1414
db, err := sql.Open("mysql", connectionString)

_integration/javascript/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ test.cb('can connect to go-mysql-server', t => {
55
const connection = mysql.createConnection({
66
host: '127.0.0.1',
77
port: 3306,
8-
user: 'user',
9-
password: 'pass',
10-
database: 'db'
8+
user: 'root',
9+
password: '',
10+
database: 'gitbase'
1111
});
1212

1313
connection.connect();
@@ -29,4 +29,4 @@ test.cb('can connect to go-mysql-server', t => {
2929
});
3030

3131
connection.end();
32-
});
32+
});

_integration/jdbc-mariadb/src/test/java/tech/sourced/jdbcmariadb/MySQLTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MySQLTest {
1414

1515
@Test
1616
void test() {
17-
String dbUrl = "jdbc:mariadb://127.0.0.1:3306/db?user=user&password=pass";
17+
String dbUrl = "jdbc:mariadb://127.0.0.1:3306/gitbase?user=root&password=";
1818
String query = "SELECT name, email FROM mytable ORDER BY name, email";
1919
List<Result> expected = new ArrayList<>();
2020
expected.add(new Result("Evil Bob", "[email protected]"));

_integration/php/tests/MySQLTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ final class MySQLTest extends TestCase
77
{
88
public function testConnection(): void {
99
try {
10-
$conn = new PDO("mysql:host=127.0.0.1:3306;dbname=db", "user", "pass");
10+
$conn = new PDO("mysql:host=127.0.0.1:3306;dbname=gitbase", "root", "");
1111
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1212

1313
$stmt = $conn->query('SELECT name, email FROM mytable ORDER BY name, email');
@@ -25,4 +25,4 @@ public function testConnection(): void {
2525
$this->assertFalse(true, $e->getMessage());
2626
}
2727
}
28-
}
28+
}

_integration/python-mysql/test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class TestMySQL(unittest.TestCase):
55

66
def test_connect(self):
77
connection = mysql.connector.connect(host='127.0.0.1',
8-
user='user',
9-
passwd='pass')
8+
user='root',
9+
passwd='')
1010

1111
try:
1212
cursor = connection.cursor()
@@ -27,4 +27,4 @@ def test_connect(self):
2727

2828

2929
if __name__ == '__main__':
30-
unittest.main()
30+
unittest.main()

_integration/python-pymysql/test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ class TestMySQL(unittest.TestCase):
55

66
def test_connect(self):
77
connection = pymysql.connect(host='127.0.0.1',
8-
user='user',
9-
password='pass',
10-
db='db',
8+
user='root',
9+
password='',
10+
db='',
1111
cursorclass=pymysql.cursors.DictCursor)
1212

1313
try:
@@ -29,4 +29,4 @@ def test_connect(self):
2929

3030

3131
if __name__ == '__main__':
32-
unittest.main()
32+
unittest.main()

_integration/python-sqlalchemy/test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
class TestMySQL(unittest.TestCase):
77

88
def test_connect(self):
9-
engine = sqlalchemy.create_engine('mysql+pymysql://user:pass@127.0.0.1:3306/test')
9+
engine = sqlalchemy.create_engine('mysql+pymysql://root:@127.0.0.1:3306/gitbase')
1010
with engine.connect() as conn:
1111
expected = {
1212
"name": {0: 'John Doe', 1: 'John Doe', 2: 'Jane Doe', 3: 'Evil Bob'},
1313
1414
"phone_numbers": {0: '["555-555-555"]', 1: '[]', 2: '[]', 3: '["555-666-555","666-666-666"]'},
15-
"created_at": {0: pd.Timestamp('2019-01-28 15:35:51'), 1: pd.Timestamp('2019-01-28 15:35:51'), 2: pd.Timestamp('2019-01-28 15:35:51'), 3: pd.Timestamp('2019-01-28 15:35:51')},
1615
}
1716

1817
repo_df = pd.read_sql_table("mytable", con=conn)
19-
20-
self.assertEqual(expected, repo_df.to_dict())
18+
d = repo_df.to_dict()
19+
del d["created_at"]
20+
self.assertEqual(expected, d)
2121

2222

2323
if __name__ == '__main__':
24-
unittest.main()
24+
unittest.main()

0 commit comments

Comments
 (0)