I tried downloading the sql (sql.lib and sqld.lib) drivers to the MSCV and MINGW files ; it did not work. I then tried through QODBC3 driver and its still not connecting to the database.
I get the following error message.
13:20:05: Starting
C:\build-test1-Desktop_Qt_5_14_1_MinGW_64_bit-Debug\test1.exe ...
13:21:17:
C:\build-test1-Desktop_Qt_5_14_1_MinGW_64_bit-Debug\test1.exe exited
with code 0
//QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3","QMYSQL");
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3","hello");
// db.setDatabaseName("Driver={MySQL ODBC 8.0 ANSI Driver};DATABASE=hello;");
db.setHostName("127.0.0.1");
db.setDatabaseName("hello");
db.setUserName("localhost");
db.setPassword("");
if (db.open()){
QMessageBox::information(this,"Connection","Database connected succesfully");
}
else {
QMessageBox::information(this,"Connection","Database not connected succesfully");
This is my code, also I did add sql in the pro files.
Related
I have simple vibe-D program which is trying to connect to SQL:
import std.stdio;
import mysql;
import vibe.d;
void main()
{
MySQLPool db_pool = new MySQLPool("localhost","root","","dbname",3306);
Connection db = db_pool.lockConnection();
// same thing happens with:
// string connectionStr = "host=localhost;port=3306;user=root;db=dbname";
// db = new Connection(connectionStr);
}
(I deleted everything else for simplification)
Dependencies:
"dependencies": {
"mysql-native": "~>3.2.0",
"vibe-d": "~>0.9.4"
}
And it fails to connect with:
object.Exception#../../../.dub/packages/vibe-core-1.22.4/vibe-core/source/vibe/core/net.d(256): Failed to connect to [0:0:0:0:0:0:0:1]:3306: refused
When I try it without vibe-d in the dub project (using phobos sockets) it connects with no problem. What am I doing wrong?
that's an ipv6 address.... is your mysql listening on that interface? might help trying 127.0.0.1 instead of localhost and seeing what happens.
can also consider reconfiguring mysql to listen on all interfaces too, including the ipv6
I am trying to connect to my pythonanywhere DB from a local python file, using the following code.
import MySQLdb, sshtunnel
sshtunnel.SSH_TIMEOUT = 5.0
sshtunnel.TUNNEL_TIMEOUT = 5.0
queryAdd = ("INSERT INTO `****$geo***`.O***"
"(name, address) "
"VALUES (%s, %s)")
with sshtunnel.SSHTunnelForwarder(
('ssh.pythonanywhere.com'),
ssh_username='*******', ssh_password='*******',
remote_bind_address=('*****.mysql.pythonanywhere-services.com', 3306)
) as tunnel:
connection = MySQLdb.connect(
user='******',
passwd='********',
host='127.0.0.1', port=tunnel.local_bind_port,
db='****$geo******',
)
cursor = connection.cursor()
for row in dl:
tup=(row['name'],row['address'])
cursor.execute(queryAdd, tup)
connection.commit()
However, as soon as the code is run, I get the following error:
MySQLdb._exceptions.OperationalError: (2013, 'Lost connection to MySQL server during query')
There is no delay between creating the connection and running the query. What am I doing wrong?
You need to do everything inside your with block as the tunnel is gone when you go outside of the context.
I am trying to connect to A DB on Redshift in r using following syntax (I am using a Mac):
odbcConnect("xxxxaddresss.redshift.amazonaws.com:5439", uid = "xxxx", pwd = "xxxx")
and get the following errors.
Warning messages:
1: In
RODBC::odbcDriverConnect("DSN=xxxxaddresss.redshift.amazonaws.com:5439;UID=xxxx;PWD=xxxx")
: [RODBC] ERROR: state IM012, code 0, message [unixODBC][Driver
Manager]DRIVER keyword syntax error
2: In
RODBC::odbcDriverConnect("DSN=xxxxaddresss.redshift.amazonaws.com:5439;UID=xxxx;PWD=xxxx")
:
ODBC connection failed
What is the reason of the problem?
I try use tarantool as application server and want connect from tarantool to mysql.
In lua i write a function:
local function mysql_data(query, limit)
local conn = mysql.connect({host = mysql_host, user = mysql_user, password = mysql_password, db = mysql_database})
local tuples = conn:execute(query, limit)
return tuples
end
but in log i see:
2016-03-29 17:57:37.358 [8553] main/101/grepmaillog_app.lua F> /home/lua/./grepmaillog_app.lua:12: module 'mysql' not found:
no field package.preload['mysql']
no file './mysql.lua'
no file './mysql/init.lua'
no file '/root/.luarocks/share/lua/5.1/mysql.lua'
no file '/root/.luarocks/share/lua/5.1/mysql/init.lua'
no file '/root/.luarocks/share/lua/mysql.lua'
no file '/root/.luarocks/share/lua/mysql/init.lua'
no file '/usr/local/share/tarantool/mysql.lua'
no file '/usr/local/share/tarantool/mysql/init.lua'
no file '/usr/share/tarantool/mysql.lua'
no f
How i can install package mysql for tarantool ?
Please install tarantool-mysql package from http://tarantool.org/download.html
Yesterday,my database file is broken,and i can't connect it.I just have the backup file before.
Now,the database files can not be attached.
标题: Microsoft SQL Server Management Studio
附加数据库 对于 服务器“BAUER”失败。 (Microsoft.SqlServer.Smo)
有关帮助信息,请单击: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.3000.0+((SQL11_PCU_Main).121019-1322+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=附加数据库+Server&LinkId=20476
其他信息:
执行 Transact-SQL 语句或批处理时发生了异常。 (Microsoft.SqlServer.ConnectionInfo)
无法在数据库“sq_mikrotiknet”(数据库 ID 为 7)的分配单元 72057594042449920,页 (1:204) 上重做事务 ID (0:10603) 的日志记录 (82:739:2)。页: LSN = (82:342:2),分配单元 = 72057594042449920,类型 = 1。日志: OpCode = 6,上下文 2,PrevPageLSN: (82:360:2)。请从数据库备份还原该数据库,或者修复它。
在重做数据库 'sq_mikrotiknet' 的日志中记录的操作时,日志记录 ID (82:739:2) 出错。通常,特定故障以前会在 Windows 事件日志服务中记录为错误。请利用完整备份还原数据库,或者修复该数据库。
无法打开新数据库 'sq_mikrotiknet'。CREATE DATABASE 中止。 (Microsoft SQL Server,错误: 3456)
有关帮助信息,请单击: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=3456&LinkId=20476
按钮:
确定