mysql

How do I retrieve an out parameter from a MySQL Stored Procedure in Python using MySQL-Connector?

自闭症网瘾萝莉.ら 提交于 2021-02-08 09:49:42
问题 I'm having trouble accessing an out parameters values from a stored procedure in MySQL(8x) using Python(3.7) and sql connector (8x). My stored procedure is an update procedure and it is working, however I don't know how to get the out value in code. Here is my stored procedure...I simply want to access the out parameter named success in python. CREATE DEFINER=`root`@`localhost` PROCEDURE `update_due_date`(param_bookId int, param_cardNumber int, param_dueDate date, out success int) BEGIN

mysql: Get last conversation records by user [duplicate]

二次信任 提交于 2021-02-08 09:49:18
问题 This question already has answers here : Retrieving the last record in each group - MySQL (29 answers) Closed 4 years ago . I need to get last conversation records by to_user in Descending order. I have table called messages. Please have a look on the following screen shot: I want the output in the following manner: from_user| to_user | message | 241 | 226 | How are you? | 241 | 256 | Hi test message | I have tried this query: SELECT * FROM `messages` where from_user=241 group by to_user

Is the order of inserts specified for INSERT IGNORE … SELECT?

旧巷老猫 提交于 2021-02-08 09:48:39
问题 I have a table like: CREATE TABLE { email VARCHAR PRIMARY, last_login DATE } And I can populate with a select result set like: ("a@b.c", "2019-01-01"), ("a@b.c", "2019-02-01") If I will insert into that table using INSERT IGNORE ... SELECT , is it specified which row gets inserted and which is ignored? Found specification: "Specify IGNORE to ignore rows that would cause duplicate-key violations." from https://dev.mysql.com/doc/refman/5.5/en/insert-select.html. But this does not say which is

mysql insert if not exist without unique key

独自空忆成欢 提交于 2021-02-08 09:40:44
问题 As discussed in MySQL: Insert record if not exists in table and https://stackoverflow.com/a/5289299/2037323 i'm trying to run following query from php and $result = mysql_query($query, $con); returns true but new records are not adding to teamshalf table. Whats wrong here? http://pastebin.com/xCqWpKcb is data that i used for both tables. One thing to mention here is that i can not use unique key here. So please tell if there is solution for non unique. INSERT teamshalf (`yearID` , `lgID` ,

INSERT & UPDATE MySql table using PySpark DataFrames and JDBC

故事扮演 提交于 2021-02-08 09:36:06
问题 I'm trying to insert and update some data on MySql using PySpark SQL DataFrames and JDBC connection. I've succeeded to insert new data using the SaveMode.Append. Is there a way to update the existing data and insert new data in MySql Table from PySpark SQL? My code to insert is: myDataFrame.write.mode(SaveMode.Append).jdbc(JDBCurl,mySqlTable,connectionProperties) If I change to SaveMode.Overwrite it deletes the full table and creates a new one, I'm looking for something like the "ON DUPLICATE

Speed up MySQL Update/Insert Statement

末鹿安然 提交于 2021-02-08 09:25:34
问题 How can I improve the following function from a speed point of view? Ideally, I'd like this to use executemany as part of this up process. While the function works fine, I'm sure there is a more efficient way to do this; check if a value exists and update/insert as applicable. I need to do this daily across millions of data. def insert_or_update(self, profile_id, landing_page, keyword, position, impressions, clicks, ctr): ''' checks if a entry exists, if not it's inserted. If it is, the

How to store large number of records in MySql database?

早过忘川 提交于 2021-02-08 09:20:10
问题 I have a table which consists of around 2500 rows for a single user id. And for each user id, same number of rows will be there. If number of users increase then I am afraid number of rows will be vast. So can you please suggest me what to do ? Should I use different tables for different users or a single table for all users. And another thing , is there any limitation of how many maximum number rows/columns can be there in a single table ? My database looks like below structure : for User1

mysql: matching a query letter by letter

家住魔仙堡 提交于 2021-02-08 09:17:37
问题 I am in the process of learning MySQL and querying, and right now working with PHP to begin with. For learning purposes I chose a small anagram solver kind of project to begin with. I found a very old English language word list on the internet freely available to use as the DB. I tried querying, find in set and full-text search matching but failed. How can I: Match a result letter by letter? For example, let's say that I have the letters S-L-A-O-G to match against the database entry. Since I

mysql: matching a query letter by letter

自闭症网瘾萝莉.ら 提交于 2021-02-08 09:17:37
问题 I am in the process of learning MySQL and querying, and right now working with PHP to begin with. For learning purposes I chose a small anagram solver kind of project to begin with. I found a very old English language word list on the internet freely available to use as the DB. I tried querying, find in set and full-text search matching but failed. How can I: Match a result letter by letter? For example, let's say that I have the letters S-L-A-O-G to match against the database entry. Since I

sequelize where date clause

帅比萌擦擦* 提交于 2021-02-08 09:13:07
问题 OS: Linux (Lubuntu) language: Javascript (Node js) framework: express js Database: mysql "data" is a Date field from "activitat" table When I run the next statement using Sequelize.js models.TblActivitat.findAll( { attributes: [ 'codiAct', 'procedencia', 'pacient', 'proces', 'prova', 'rmn', 'realitzador', [Sequelize.fn('date_format', Sequelize.col('data'), '%d-%m-%Y'), 'data'] ], include: models.TblTecnics, where: {"data": '2016-10-20' }, //dataAAAAMMDD order: "registre DESC" }).then(function