mysql-connector

Obtaining Table metadata from mysql in java

ⅰ亾dé卋堺 提交于 2019-12-09 01:43:02
问题 Is there a way to get table metadata before first executing select query on the table? Restated: Is there a way to get the column size of a specific row and column of data for the numeric types: int, tinyint, bigint, etc? DatabaseMetaData md = connection.getMetaData(); ResultSet rs = dbmd.getColumns(null, null, tableName, "%"); I can't use the above code as the COLUMN_SIZE for numeric type( int,tinyint,bigint,etc ) will return the maximum allowed size for these types. I need to get the

inserting data using mysql Connector in python

徘徊边缘 提交于 2019-12-08 17:18:53
问题 i've faced an wired problem that's when i'am about to insert data into my database it's not inserting and not failing (throwing exception) either ! ,, when data is duplicated or wrong table provided it's throws exceptions !! here's my code ! from mysql import connector con = connector.Connect(user='root',password='root',database='test',host='localhost') cur=con.cursor() cur.execute("""insert into user values ('userName', 'passWord')""") the database test include only one table which is users

Linker warnings while building application against mysql-connector-c/libmysqlclient/mysql C API

喜欢而已 提交于 2019-12-08 15:50:00
问题 I am trying to build mysql-connector-c from source(per instructions here) and statically link against the library in my application. However I am getting the following warnings and I was wondering if anyone has any ideas as to why this is: /path/to/lib/libmysqlclient.a(mf_pack.c.o): In function `unpack_dirname': mf_pack.c:(.text+0x90b): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /path/to/lib

“'utf-8' codec can't decode byte” when querying string in MySQL

拈花ヽ惹草 提交于 2019-12-08 11:35:21
问题 I'm quering to see if a particular URL exists in my table: query = 'SELECT EXISTS(SELECT * FROM table WHERE LINK = %s)' c.execute(query, [link]) result = c.fetchall()[0][0] If I set link equal to "https://www.reuters.com/article/us-mideast-iran-tanker/iran-threatens-british-shipping-in-retaliation-for-tanker-seizure-idUSKCN1U00S5", it works fine. But when I specifically try: query = 'SELECT EXISTS(SELECT * FROM table WHERE LINK = %s)' c.execute(query, [" https://www.reuters.com/article/brief

MySQL Connector/python not working in django

允我心安 提交于 2019-12-08 06:15:26
问题 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

pandas dataframe to mariadb database with to_sql and sqlalchemy

风流意气都作罢 提交于 2019-12-08 04:31:51
问题 I want to use the pandas function to_sql to write a dataframe into a MariaDB database. My Python code inside PyCharm looks as follows: import pandas as pd import mysql.connector from sqlalchemy import create_engine myd = pd.read_csv('/[path]/[filename].csv') engine = create_engine('mysql+mysqlconnector://[user]:[pw]@127.0.0.1/[dbname]') myd.to_sql(name='[tablename]', con=engine, if_exists='replace', index=False) When executing the last line in the console I get the following error: Error on

MySQL Connector/C++ Library Linking ERROR Problem

感情迁移 提交于 2019-12-08 03:24:10
问题 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

Can you use MySQL @ session variables in the C# connector?

安稳与你 提交于 2019-12-08 02:49:52
问题 I have a query that utilizes MySQL session variables (note the @rank variable) SELECT Rank, UserId, CurrentVDOT FROM ( SELECT @rank := @rank + 1 AS Rank, UserId, MaxVDOT AS CurrentVDOT FROM ( SELECT UserId, MAX(VDOT) AS MaxVDOT FROM ( SELECT U.UserId, U.VDOT FROM ( SELECT UserId, MAX(Created) AS Created FROM UserVDOT GROUP BY UserId ) G INNER JOIN UserVDOT U ON U.UserId = G.UserId AND U.Created = G.Created ) M GROUP BY UserId ORDER BY MaxVDOT DESC ) R, (SELECT @rank := 0) foo ) F WHERE F

No suitable driver found for jdbc:mysql netbeans, *.jar include in library

天大地大妈咪最大 提交于 2019-12-08 02:32:27
问题 I can perform the connection in worbanch, but with the same username and password can not connect through the application in the mysql database. I checked the syntax apparently seems to be correct. I would like to help to solve this problem as the .jar is already in the library folder of Java SE project. print screen: Screen 1 screen 2 ERROR CONSOLE: No suitable driver found for jdbc:mysql://127.0.0.1/sakila 回答1: Just simply add the library to your project library. Right click in Library on

Entity framework returning incorrect data from columns with same name

陌路散爱 提交于 2019-12-08 02:04:12
问题 I have a few tables in my database which are mapped to an edmx. Using the entity framework to return data from these tables, I've encountered a problem where the value in the "name" column from one of my higher level data models is being populated into each model below it. I'm pulling the data like this: var query = (from a in context.things where a.id == 1 select a); var model = query.Select(a => new modelA() { Name = a.name, Bs = a.Bs.Select(b => new modelB() { Name = b.name, Cs = b.Cs