mysql

How to manage User Roles in a Database?

Hi all, I'm creating a website in which I will be managing users and their permissions. I am looking to implement user roles, and can't seem to wrap my head around how things should work. I want to be able to assign a user a certain role, and have each role contain one to several permissions that can be read easily by my script. Just wa...

Insert the rows of 'report_temp' which are not in 'report'?

I've two tables : report (reportID, VendorName, VendorID, MfgDate, PurchaseDate, etc.,) In report table reportID is primary key. report_temp has the same set of columns as report, but not any constraints. I've to insert the rows from report_temp to report where the reportID is not the same. I've written as INSERT INTO report(rep...

Problem selecting the latest record in JOIN

These are my 2 tables: CREATE TABLE `documents` ( `Document_ID` int(10) NOT NULL auto_increment, `Document_FolderID` int(10) NOT NULL, `Document_Name` varchar(150) NOT NULL, PRIMARY KEY (`Document_ID`), KEY `Document_FolderID` (`Document_FolderID`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=331 ; CREATE TABLE `fil...

How to retrieve a time stamp with the right formatting from a sql database using python

I want to retrieve a time stamp from a sql database with proper formatting. This is the partial code I am using: import MySQLdb def connectDB(self): global cursor DATABASE = MySQLdb.connect( host = self.HOST, user = self.USER, passwd = self.PASS, db = self.DB, port = self.P...

SQL query for finding row with same column values that was created most recently

If I have three columns in my MySQL table people, say id, name, created where name is a string and created is a timestamp.. what's the appropriate query for a scenario where I have 10 rows and each row has a record with a name. The names could have a unique id, but a similar name none the less. So you can have three Bob's, two Mary's, on...

Ensure `INSERT`s are concurrent for a specific MyISAM table?

I have a MyISAM table that basically contains a log. A cluster of machines does single-record INSERTs on this table at a rate of 50 per second tops, but the same table is also SELECTed from by a web application, and indexed to accommodate for this. There are no UPDATEs or DELETEs, though. So from what I've gathered, I should be using co...

automatically placing results of a called procedure into a select statement

I'm playing with some code from an article written by Peter Brawley found here on page 6 of the pdf. I'm trying to figure out how to automate it so that the result of the procedure is automatically placed in the select query. Right now what I am doing is calling the procedure, exporting the result into a text file, going to the text fi...

Optimal MySQL temporary tables (memory tables) configuration?

Hello, excuse my english First of all, I am new to optimizing mysql. The fact is that I have in my web application (around 400 queries per second), a query that uses a GROUP BY that i can´t avoid and that is the cause of creating temporary tables. My configuration was: max_heap_table_size = 16M tmp_table_size = 32M The result: temp ...

MySQL Unique Identifier

We are trying to develop a system where a person creates an account where the username is the person's email address. The problem is, the person can have his own unique account (where he is the admin), plus be a "user" of someone else's account. The "admin" of an account would be able to assign a person's email address to their account...

mysql IFNULL ELSE

I have a select statement where I want to make select conditional like this IFNULL(field_a,field_a,feild_b) so that it checks field a if a is null then the select would be field b is that possible ? ...

mysql manual increment ids?

I have a table with items in it (id, name, etc) and I want some kind of database scheme to be able to have multiple copies of the item while still being able to increment the ids. There will be a field called startdate or date_from_which_this_entry_should_be_used. I've thought of two ways of implementing this: Have a table with only i...

phpMyAdmin disable admin login

Hi, I have Ubuntu, and installed the phpMyAdmin package (currently 4:3.3.2-1). Every 30 minutes, it asks me to enter my username and password, for inactive session timeout. In earlier version of phpMyAdmin, setting a user/pass would entirely skip this login form and keep the session open indefinitely. This installation is on a dev machin...

MySQLdb Handle Row Lock

I'm using MySQLdb and when I perform an UPDATE to a table row I sometimes get an infinite process hang. At first I thought, maybe its COMMIT since the table is Innodb, but even with autocommit(True) and db.commit() after each update I still get the hang. Is it possible there is a row lock and the query just fails to carry out? Is there...

Simple Foreign key / Create View question

What am I doing wrong? I need to create the foreign key but the code begining at CONSTRAINT is wrong somehow, also I need help with my view I think im doing the subquery wrong can you help me? CREATE TABLE dealer( dealershipId CHAR(10), phone CHAR(10), dealershipName CHAR(10), webAddress char (10), street CHAR (10), city char (10), zip ...

Is there LIKE IN in mysql?

Possible Duplicate: Is there a combination of LIKE and IN in SQL? Is there LIKE IN in mysql? ...

IntegrityError when saving user with username=email

I have modified my application, so that when a new user is registered, it's username and email are the same. But when a new user is created, I'm getting IntegrityError : (1062, "Duplicate entry '[email protected]' for key 'username'"), still the user is created correctly. Function register_new in which a new user is created ('temp_data' is a ...

C++ Mysql Real Escape String Issue

Hmm, for some reason, its only doing this on the first username (and password) and does it for how big my my vector is. Any ideas on why? int eMysql::strip(string &input) { char* from = new char[strlen(input.c_str()) * 3 + 1]; mysql_real_escape_string(&mysql, from, input.c_str(), input.length()); input = input.assign(from); ...

copy mysql database into firebird/interbase

I have a client that uses the mysql database to enter data, but he wants the data can be read with accurate program that uses the Firebird database. Is there a solution to move data in mysql to a Firebird database? ...

Sending a notification when a MySql database entry changes

I've written a php file that changes a MySql table entry when it receives an http post. I would also like the php file to send out a notification to the table entry's owner. This idea is similar to a chat room or instant messengering program. I've looked at php chat scripts but I really need something that has a very simple interface tha...

can't turn off mysql query cache on mac (macports install)

I'm trying to turn off mysql query cache on my local mac dev machine. I've tried via the CL: SELECT sql_no_cache; RESET query cache; SET SESSION query_cache_type = OFF; and also in the config: query-cache-type = 0 I installed it via macports. There are about 10 my.cnf files so maybe I'm not even editing the correct on? /private/e...