mysql

Trapping MySQL Warnings In Python

I would like to catch and log MySQL warnings in Python. For example, MySQL issues a warning to standard error if you submit 'DROP DATABASE IF EXISTS database_of_armaments' when no such database exists. I would like to catch this and log it, but even in the try/else syntax the warning message still appears. The try/except syntax does ca...

SQL, Order By - How to give more authority to other columns?

Hello all, I have this SQL statement: SELECT * FROM converts WHERE email='[email protected]' AND status!='1' ORDER BY date ASC, priority DESC This just orders by date but I want to give my column "priority" more authority. How can I do this? It should order by date first but if the time between two records is 10 mintues then...

How do I migrate my website, mySQL, php pages, files, settings etc to Amazon EC2?

Hi I am completely new to EC2 and new to server admin and have been working on a windows 2003 server with our current web application made with PHP pages, mySQL database, and serving image files from a single standalone windows 2003 server. I would like to know how to go about 'packing up' our server and installing it as an image on Am...

Filtering from join-table

I'm having some trouble with a tricky SQL-query. In my MySQL database there is the tables topics, tags and tags_topics to join them. I want to fetch topics that share the same specified tags. For example, let's say i have 3 tags with ids 1, 2 and 3, i want to fetch all topics that have tag 1, 2 and 3 associated to them. The topics can ...

Why would print_r ($row); only be returning a number 1?

I am trying to learn PHP5 and am having a couple of problems with it. I am working with prepared statements and am trying to run the following code: <?php require_once 'includes/config.php'; $conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or die('There was a problem connecting to the database.'); $query = "SELECT * FROM...

Whats a fast alternative to plain fulltext searching in php?

Im looking to improve the search in one of my applications, where I sue regular fulltext searching, which isn't too bad, but Im looking to add some more complex behaviors, such as typo recognition and better relevancy. Are there any solutions out there that can be integrated into an existing application? Im looking to search several tab...

How to pivot a MySQL entity-attribute-value schema

I need to design tables which stores all the (Attributes) metadata of Files i.e., FileName, Author, Title, CreatedDate ... and Custom Metadata ( Metadata added to files by Users) Before examining the tables we can not say what and how many custom tags have been added on Files. Custom Tags i.i.e, CustUseBy, CustSendBy etc. Now To store ...

InnoDB hidden auto-increment and Dual Masters

When an InnoDB table is created without a primary key a "hidden" auto inc key is created and used for indexes. Does anyone know if this key is multi-master safe? If setting up auto incs in a database that was to be multi-master the standard mysql approach is to set auto_increment_increment and auto_increment_offset to appropriate values...

Where should I store my database username and password in a PHP application?

This is probably true for other languages as well. I've created several websites by now, many of which use databases (usually mySQL). I need to store the database password somewhere in the sourcecode, but this seems like a security problem, and a a bit like a hack. Is there a better way to store the password, apart from a config file whi...

How to send data in PHP without content-length?

I know it's possible, but I can't seem to figure it out. I have a mySQL query that has a couple hundred thousand results. I want to be able to send the results, but it seems the response requires content-length header to start downloading. In phpMyAdmin, if you go to export a database, it starts the download right away, FF just says u...

How to show the last queries executed on MySQL?

There are any query/way to show the last queries executed on ALL the server? ...

Complex Database Backup

i am required to back up certain rows from certain tables from a database. often the criteria requires joins and such. what's a good way to accomplish this? (i don't have to use mysqldump). ...

C# Parameterized Query MySQL with `in` clause

I am in the process of converting several queries which were hard-coded into the application and built on the fly to parameterized queries. I'm having trouble with one particular query, which has an in clause: UPDATE TABLE_1 SET STATUS = 4 WHERE ID IN (1, 14, 145, 43); The first parameter is easy, as it's just a normal parameter: MyS...

MySQL query (mixing an insert with select)

I have a bunch of rows in a table with columns a, b, c. I'd like to be able to SELECT all rows where say a = 1, and reinsert them with a = 2. Essentially keeping all the rows where column a exist as is, and having a new batch of rows having as a = 2. What's the best query to establish such a multi-INSERT query? This is all happening in t...

Partially null dates in MySQL/Django

I'm currently converting my site from PHP to Django, but as I'm new to Python I'm struggling to get my head around a few thingss. Sometimes I have incomplete dates in my database (ie I may not know the day or even the month), so currently have three integer fields: date_year, date_month and date_day. I noticed that MySQL accepted 'part...

Trappings MySQL Warnings on Calls Wrapped in Classes -- Python

I can't get Python's try/else blocks to catch MySQL warnings when the execution statements are wrapped in classes. I have a class that has as a MySQL connection object as an attribute, a MySQL cursor object as another, and a method that run queries through that cursor object. The cursor is itself wrapped in a class. These seem to run ...

Does MySQL cache insert queries?

When I run a large MySQL query that inserts 50k records (with 10 small columns) into the database, my query cache usage spikes from around 10MB to 400MB. Is MySQL caching my insert? ...

Database design, how to setup tables

I have a simple ecommerce type site that will have users with accounts, orders, and contact/billing information for those users. I just wanted to know the best way to setup these tables from an efficiency and logical point of view. So far I have basically two different entities, users and orders. Users will have basic account information...

Can you have multiple MySqlCommand's in a single transaction?

I want to do an insert and an update on 2 separate tables, but have them be in 1 transaction). Essentially in pseudocode I want to do something like: MySqlTransaction trans = null; try { _Connection.Open(); trans = _Connection.BeginTransaction(); insertCmd.Transaction = trans; updateCmd.Transaction = trans; Int32 i...

What is the advantage of using try {} catch {} versus if {} else {}

I am switching from plain mysql in php to PDO and I have noticed that the common way to test for errors is using a try / catch combination instead of if / else combinations. What is the advantage of that method, can I use one try / catch block instead of several nested if / else blocks to handle all errors for the different steps (conne...