mysql

how to add new column on elixir

i use elixir as orm for mysql database,now i want to add new column to my schema,how could i keep orginal data in the mysql and update the schema automatically,the concept called migrate on ruby on rails,it seems i didn't found relevent infomation & code in sqlalchemy & elixir,any advice is welcome. ...

MySQL:set result two digits behind comma

i have some formula: CONCAT((SUM(X.lot_qty)-SUM(X.reject))/SUM(X.accept)*100,'%') AS Acceptance but i get result like: 100.0000% how to get result as 100.00%? ...

Is it possible to get database contents from any website without having DB access ?

I want to retrieve the database contents from a website and use it in another website. Is it possible to access the database contents using any scripts ? There are totally 500 + products in the website and they are going to remove those contents now. So before they remove them i want to download all the data and host it in my website. It...

MySQL Conditional Replication based on Records

Hey there, Our organization has a very large database which Replicates to separate global servers. In our database some tables contain data exclusive to a certain region thus providing privileges to exclusive information to users who are within those regions. example ( transactions_australia, transactions_dubai ) Contrary t...

Escaping unicode strings for MySQL in Python (avoiding exceptions.UnicodeEncodeError)

I am using Twisted to asynchronously access our database in Python. My code looks like this: from twisted.enterprise import adbapi from MySQLdb import _mysql as mysql ... txn.execute(""" INSERT INTO users_accounts_data_snapshots (accountid, programid, fieldid, value, timestamp, jobid) VALUES ('%s', '%s', '%s', '%s', '%s', '%s...

MYSQL ERROR 1064 (42000) - error in SQL syntax

I'm importing some entries into a MYSQL table and it breaks on one of the INSERT statements with the following error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'reqSent', 'Your 1-on-1 Request has been sent', '& (3996, 'reqSent...

MySQL statement convert to pretty Rails AR Statement?

Hi Guys, I have a MySQL statement that took me all night to come up with. I'm wondering if this thing can be converted from a direct call to something pretty like Object.find(:conditions) ActiveRecord::Base.connection.execute(" SELECT *, (SELECT COUNT(*) FROM scores AS temp2 WHERE temp2.score > scores.scor...

Dedicated Server / Servers Recommendation

Hello guys, I'm working on project based on Affiliate Product Data Feeds, I need to parse a lot of XML files sometimes their size is up to 300MB. I develop with PHP and Mysql. Please what you recommend for me. is a dedicated server with 4Gb Ram can support large XML files parsing? ...

Prepared Statement: Call to member function on non-object.

public function endGame($result) { $sql = "UPDATE games SET result = ? WHERE id = ?"; $stmt = $this->db->prepare($sql); $stmt->bind_param("si", $result, $this->currentGame);//Error here $stmt->execute(); $stmt->close(); } mysql> describe games; +-------------+-------------+------+-----+---------+----------------+ |...

Timeout a query

Hi, I wanted to know if we can timeout a sql query. In the sense, that suppose I have a sql query whose output is useful only if gives the output in 10 minutes ,after which even if it outputs the results its of no use to me. What I want to do is that if the query takes more than 10 minutes to do the processing then it should just kind...

Issue writing MySQL query to find difference

I'm having trouble with sorting out a query for the following: Data: Column1 Column2 2 0 0 -2 I'm trying to select the difference between Column1 and Column2, with a minimum of 0. Eg. Row1=2 Row2=0 My current query is SELECT (Column1 - Column2) as total FROM blah. I tried adding max(Column2, 0) into the query, but t...

How to add a particular field to all table if it is not exists?

I want to add a field name called UserId datatpe varchar(25) in all the tables.If the table already contains this field I dont want to add.Is it possible by using SQL query.Please give me some Ideas. ...

Returning the average amount of a column

I have a table which represents the scores and id's of users who have played a flash game. I want to return the amount of times the average user has tried the game- every time they complete a "try" the score and id of the user is input into the mysql table. The structure is - id int(11) score int(11) ...

PHP/MySQL get name where id = id

Hi, I have one mysql table with results assigned a category id, and a seperate table that lists all of the categories by name with their respective id's. All of the results are grouped by their id's and the id is displayed as the heading. How do I display the id as its respective name from the other database? Here is the full code I'm...

mysql query to select one specific row and another random row.

Hi all. I want to display two records. For eg select * FROM users WHERE user_id = 5. Now i want another row randomly selected from users table but with user_id != 5 Is it possible to do in a single query. I tried using union all but i dnt get two distinct rows. Thanks ...

Rails - Make a one-off query to a different database and table.

Hi, I have a rails app with a wordpress blog sellotaped on the side (totally separately at /blog). The client want's to the latest blog post on the main homepage of the rails app, so I need to do a one-off mysql query to the word-press database. How would I go about doing this in the rails app. The word-press is completely sperate from...

PHP - Logging into many MSN's

Hi, In PHP what method or way would you use to login into many different MSN accounts? I researched and its SOCKETS/fopen related stuff. I could load up the MSN accounts via MYSQL. Post your method and thanks. ...

How to solve problems with deadlocks in InnoDB engine?

I have heard about this problem and now I am looking for more specific information? How does it happens, what are the reasons for that, detailed explanation of the mechanism of the deadlock to try to avoid it. How to detect the deadlock, solve it and protect the data from being corrupted because of it. The case is when using MySQL with ...

Import file size limit in PHPMyAdmin

I have changed all the php.ini parameters I know: upload_max_filesize, post_max_size. Why am I still seeing 2MB? Im using Zend Server CE, on a Ubuntu VirtualBox over Windows 7 host. ...

First record not picked up in pagination script (despite the fact it is set to show all records > NOW() as query)

This is my pagination script, which I've been working on: http://pastebin.com/4mpjdWKD This is the query page which displays the records - but it omits the first record: http://pastebin.com/kJZy9fv0 The actual query is this: <?php //Require the file that contains the required classes include("pmcPagination.php"); //Php...