mysql-connector

Getting MySQL record count with C#

醉酒当歌 提交于 2019-12-07 12:24:47
问题 I would like to know how can I get record count of a query with C#. Here is the code that I use.. MySqlDataReader recordset = null; query = new MySqlCommand("SELECT * FROM test ORDER BY type_ID ASC", this.conn); recordset = query.ExecuteReader(); while (recordset.Read()) { result.Add(recordset["type_ID"].ToString()); } return result; 回答1: I was using a SELECT COUNT(*) and expected an int to be returned. You may need this to get a usable value: mysqlint = int.Parse(query.ExecuteScalar()

MySqlDataReader: DataTable.Fill(reader) throws ConstraintException

霸气de小男生 提交于 2019-12-07 08:10:37
问题 I have two tables orders and orderdetails table orders (PK = id, UNIQUE index on orderno) |id|orderno| | 1|1000 | | 2|1001 | table orderdetails (PK = id) |id|orderid|item|qty| | 1| 1|ABC | 3| | 2| 1|XYZ | 4| Now I want to query the data with: SELECT o.orderno, od.item, od.qty FROM orders o INNER JOIN orderdetails od ON o.orderno = od.order which returns: |orderno|item|qty| |1000 |ABC | 3| |1000 |XYZ | 4| However If I use the following code to load the result into a DataTable it fails: var

Memory leak in MySQL C++ Connector

纵饮孤独 提交于 2019-12-07 06:36:25
问题 I am using MySQL C++ connector. Valgrind is showing it is leaking 192 bytes on every connection. It is leaking memory only in threaded environment without threading it is not leaking any memory.What I am doing wrong ? Do I need to call some other functions for cleanup ? Sample code: #include <pthread.h> #include <iostream> #include <cppconn/driver.h> #include <cppconn/exception.h> #include <cppconn/resultset.h> #include <cppconn/statement.h> #include <cppconn/prepared_statement.h> using

mysql-connector python 'IN' operator stored as list

穿精又带淫゛_ 提交于 2019-12-07 06:02:48
问题 I am using mysql-connector with python and have a query like this: SELECT avg(downloadtime) FROM tb_npp where date(date) between %s and %s and host like %s",(s_date,e_date,"%" + dc + "%") NOw, if my variable 'dc' is a list like this: dc = ['sjc','iad','las'] Then I have a mysql query like below: SELECT avg(downloadtime) FROM tb_npp where date(date) = '2013-07-01' and substring(host,6,3) in ('sjc','las'); My question is, how do I write this query in my python code which will convert my

How to avoid “There is already an open DataReader associated with this Connection which must be closed first.” in MySql/net connector?

Deadly 提交于 2019-12-07 04:17:08
问题 I have this following piece of code: public TimestampedRowStorage GetTimestampedRowStorage(string startTime, string endTime, long trendSettingID, int? period) { var timestampedList = (from t in dataContext.TrendRecords where t.TrendSetting_ID == trendSettingID select t).ToList(); return new TimestampedRowStorage { TimestampedDictionary = timestampedList.ToDictionary(m => m.Timestamp, m => (from j in dataContext.TrendSignalRecords where j.TrendRecord_ID == m.ID select j).ToDictionary(p => p

Unable to connect to any of the specified MySQL hosts - MySQL connector 6.8.3 and ASP MVC5

狂风中的少年 提交于 2019-12-06 17:12:11
问题 After a whole day trying dozen of solutions I'm really stuck here. I get the infamous Unable to connect to any of the specified MySQL hosts error. It's a very generic error so I already tried a few things. First some details that hopefully will help: I'm using: Entity Framework 6 ASP.NET MVC 5 MySQL with MySQL Connector 6.8.3 Everything works when I run the application in Visual Studio 2013. It connects to the MySQL server with no problems, so i suppose there's nothing wrong with my

Connector/c++ with SSL?

我的未来我决定 提交于 2019-12-06 16:13:07
问题 How to connect to MySql using Connector/c++ over SSL? I read about mysql_ssl_set(): seems to work only with Connector/c. I have openSSL enabled and working for require SSL users on MySql. And I can connect remotely to MySql using Connector/c++, but cannot see how to modify parameters of sql::Connection to reference certs for SSL. Excellent tutorial from Giri Mandalika at MySql DevZone and docs on Connector/c++ don't mention SSL, which surprised me because SSL is well documented for Connector

MySQL Connect/C++ 64 bit build error

牧云@^-^@ 提交于 2019-12-06 16:00:21
问题 I am using Netbeans and MacoSX and installed 64bit connector. On building I am getting following errors: /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf /usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/GNU-MacOSX/inventory mkdir -p build/Debug/GNU-MacOSX rm -f build/Debug/GNU-MacOSX/addproduct.o.d g++ -c -g -Iinclude -Iinclude -MMD -MP -MF build/Debug/GNU-MacOSX/addproduct.o.d -o build/Debug/GNU-MacOSX/addproduct.o addproduct.cpp from addproduct.cpp:10: In file

MySQL Connector/python not working in django

送分小仙女□ 提交于 2019-12-06 14:43:43
I'm learning Django with MySQL as backend. I installed Oracle's mysql connector to connect with mysql. However, when I run python manage.py I got this error Traceback (most recent call last): File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 14, in import MySQLdb as Database ImportError: No module named 'MySQLdb' That's a bit weird. I was thinking if I installed mysql connector/python I dont need MySQLdb anymore. Could anyone help explain? Thanks! My database setting: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': "djangolearn", 'USER': 'root

MySQL Connector/C++ Library Linking ERROR Problem

六月ゝ 毕业季﹏ 提交于 2019-12-06 13:28:58
PROBLEM: Ok, I've been TRYING to follow the sample code on the MySQL Forge Wiki and some other websites that offer a tutorial on how to get a simple database connection, but for some reason, my project always fails at a linking error and I can't figure out why or how to fix it myself (I'm still learning). PLEASE HELP ME! I've included the path directory needed for the header files in the project properties AND provided the path directory to the lib files that are used in the MySQL Connector/C++. The code I'm using is below if someone could give me a helpful hint/ comment on how to fix it. I