mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
mysql: connection fixes (#18428)
This commit is contained in:
committed by
GitHub
parent
7f178d4662
commit
f634f7b01f
@@ -1,14 +1,13 @@
|
||||
import db.mysql
|
||||
|
||||
fn main() {
|
||||
mut conn := mysql.Connection{
|
||||
mut conn := mysql.connect(
|
||||
host: 'localhost'
|
||||
port: 3306
|
||||
username: 'root'
|
||||
password: ''
|
||||
dbname: 'mysql'
|
||||
}
|
||||
conn.connect()!
|
||||
)!
|
||||
res := conn.query('show tables')!
|
||||
for row in res.rows() {
|
||||
println(row.vals.join(', '))
|
||||
|
||||
@@ -102,14 +102,13 @@ fn sqlite3_array() ! {
|
||||
|
||||
fn msql_array() ! {
|
||||
eprintln('------------ ${@METHOD} -----------------')
|
||||
mut db := mysql.Connection{
|
||||
mut db := mysql.connect(
|
||||
host: mysql_host
|
||||
port: mysql_port
|
||||
username: mysql_user
|
||||
password: mysql_pass
|
||||
dbname: mysql_db
|
||||
}
|
||||
db.connect()!
|
||||
)!
|
||||
defer {
|
||||
sql db {
|
||||
drop table Parent
|
||||
@@ -213,14 +212,13 @@ fn sqlite3() ! {
|
||||
|
||||
fn msql() ! {
|
||||
eprintln('------------ ${@METHOD} -----------------')
|
||||
mut conn := mysql.Connection{
|
||||
mut conn := mysql.connect(
|
||||
host: mysql_host
|
||||
port: mysql_port
|
||||
username: mysql_user
|
||||
password: mysql_pass
|
||||
dbname: mysql_db
|
||||
}
|
||||
conn.connect()!
|
||||
)!
|
||||
defer {
|
||||
conn.query('DROP TABLE IF EXISTS Module') or { eprintln(err) }
|
||||
conn.query('DROP TABLE IF EXISTS User') or { eprintln(err) }
|
||||
|
||||
Reference in New Issue
Block a user