mysql

How do you debug MySQL stored procedures?

My current process for debugging stored procedures is very simple. I create a table called "debug" where I insert variable values from the stored procedure as it runs. This allows me to see the value of any variable at a given point in the script, but is there a better way to debug MySQL stored procedures? ...

MySQL - Select from a list of numbers those without a counterpart in the id field of a table

I have a list of numbers, say {2,4,5,6,7} I have a table, foos, with foos.ID, including say, {1,2,3,4,8,9} Id like to take my list of numbers, and find those without a counterpart in the ID field of my table. One way to achieve this would be to create a table bars, loaded with {2,4,5,6,7} in the ID field. Then, I would do SELECT bar...

We're using JDBC+XMLRPC+Tomcat+MySQL to execute potentially large MySQL queries. What is a better way?

I'm working on a Java based project that has a client program which needs to connect to a MySQL database on a remote server. This was implemented is as follows: Use JDBC to write the SQL queries to be executed which are then hosted as a servlet using Apache Tomcat and made accessible via XML-RPC. The client code uses XML-RPC to remotely...

MySQL: How to determine foreign key relationships programmatically?

Similar to this question but for MySQL.... How can I programmatically determine foreign key references in MySQL (assuming InnoDB)? I can almost get them with: SHOW TABLE STATUS WHERE Name = 'MyTableName'; ...but alas, the comment column which seems to contain some of this info gets truncated so I can't rely on it. There must be som...

Getting distinct records from a mysql query

In my application, there are publishers and categories. One publisher can belong to several categories. When I make my mysql transaction, it will return the same publisher record for each category it belongs to. Here's the query: SELECT grdirect_publisher.name, grdirect_publisher.short_description, grdirect_publisher.thum...

What is the equivalent of Oracle’s REF CURSOR in MySQL when using JDBC?

In Oracle I can declare a reference cursor... TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE; ...and use it to pass a cursor as the return value... FUNCTION end_spool RETURN t_spool AS v_spool t_spool; BEGIN COMMIT; OPEN v_spool FOR SELECT * FROM ...

Php - Connecting to remote database very slow

I have a new VPS server, and I'm trying to get it to connect to another server at the same ISP. When I connect via mysql's command line tool, the connection is very fast. When I use PHP to connect to the remote DB, the connection time may take up to 5 seconds. Queries after this are executed quickly. This is not limited to mysql, usi...

How do you connect to multiple MySQL databases on a single webpage?

I have information spread out across a few databases and want to put all the information onto one webpage using PHP. I was wondering how I can connect to multiple databases on a single PHP webpage. I know how to connect to a single database using: $dbh = mysql_connect($hostname, $username, $password) or die("Unable to connect...

mysql c api row[0] to string

When using MYSQL C API to query results. The results are returnd as a MYSQL_ROW type, which according to the MYSQL C API documentation, I can easily printf("%s", row[0] ). But what if I want to transfer the contents of row[0] into a string or a char*? ...

information seemingly coming out of mysqldb incorrectly, python django

In a latin-1 database i have '\222\222\223\225', when I try to pull this field from the django models I get back u'\u2019\u2019\u201c\u2022'. from django.db import connection (Pdb) cursor = connection.cursor() (Pdb) cursor.execute("SELECT Password from campaignusers WHERE UserID=26") (Pdb) row = cursor.fetchone() So I step into that an...

Database change underneath SQLObject

I'm starting a web project that likely should be fine with SQLite. I have SQLObject on top of it, but thinking long term here -- if this project should require a more robust (e.g. able to handle high traffic), I will need to have a transition plan ready. My questions: How easy is it to transition from one DB (SQLite) to another (MySQ...

What is a good solution for deploying a PHP/MySQL site via FTP?

I am currently working on a web application that uses PHP and MySQL, but I do not have shell access to the server (working on that problem already...). Currently, I have source control with subversion on my local computer and I have a database on the local computer that I make all changes to. Then, once I've tested all the updates on m...

auto_increment causing errors with CREATE TABLE

I have been using netbeans as a tool for my java, and i have a problem. I read this tutorial and then i tried to create a table using this SQL: CREATE TABLE CUSTOMERS ( ID INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, FIRST_NAME VARCHAR(20), LAST_NAME VARCHAR(30), ADDRESS VARCHAR(30), CITY VARCHAR(30), STATE_ VARC...

Change each record in a table with no primary key?

I have a table in a database that represents dates textually (i.e. "2008-11-09") and I would like to replace them with the UNIX timestamp. However, I don't think that MySQL is capable of doing the conversion on its own, so I'd like to write a little script to do the conversion. The way I can think to do it involves getting all the record...

Parsing Integers out of a string in SQL

I have a fairly large database with with a column that has strings that are for the most part really just ints, e.g. "1234" or "345". However some of them have strings prepended to them (of varying length), so e.g. "a123" or "abc123". Is there a smart way to create a new column with just the integer values? Thus, "abc123" would become ...

Can I concatenate multiple MySQL rows into one field?

Using MySQL, I can do something like select hobbies from peoples_hobbies where person_id = 5; and get: shopping fishing coding but instead I just want 1 row, 1 col: shopping, fishing, coding The reason is that I'm selecting multiple values from multiple tables, and after all the joins I've got a lot more rows than I'd like. I'v...

How to filter a list of items in a MySQL database?

I have list store in mysql table file1=(1,2,3,4,6,7) and other list file2 = (3,2,4,8,9,10,12) is not stored in table, i want compare both and result should be like result=(6,7,8,9,10,12) then calculate the percentage. like 100*(result/file1+file2) in mysql data structure. i do not know how i will do it. please know body know guide me or...

MySql: MyISAM vs. Inno DB!

What are the differences between MyISAM and Inno DB types in MySql? ...

Shouldn't mysql_real_escape_string() leave slashes in Database?

Hello Im using smarty and mysql_real_escape_string() for user input, and when I insert some code with ' or " , and lookup in phpmyadmin it shows without backslashes. When I get record from DB i doesn't have backslashes also. But when I just pass escaped string without inserting into the db it is backslashed. Shouldn't it add slashes, ...

ebay query into mysql?

Hello, I would like to know if it is possible, To extract the userid from an ebay page and insert it into mysql as part of an insert statement? Otherwise what would be the best way to do this? I have files to import, which contain hundred of ebay auction urls, and I must grab the seller id from each one. Is there an easier way to do th...