every time I try to execute a new action I get an error. I guess it's because some of the previuos actions can't be executed twice, but in the tutorial I'm watching, the guy can do it without problems. How can I fix this?
Thanks in advance!
If the error you are referring to is the 'Table...already exists', it looks like you may want to start your script with:
drop database if exists ContactMe;
That will remove all tables and data in that database.
"action" is some concept invented by the UI you are using, by the way, not something that has any specific meaning in mysql.
Related
I have created a table named dbms
it runs once well but when I try to run again, it shows an error that dbms table already exists.
I don't understand what is the problem
can anyone help me, please?
thank you.
when working with databases, you only need to run the script once to create it. Otherwise it will not show until you place data into it.
thank you, everyone.
but I found my mistake.
I was running the whole code again and again.
I just need to run a single line of code or a particular set of lines that need to be excecuted.
Today I have tried to fire the job that checks for the redundancy in the particular table.
I have one table EmpDetails
Please find the screenshot to find the records in the table
A job runs from the sql in every 2 min and delete the redundancy from the table.
Result of the job: :
But my expectations from the job are some bit higher, I want from the job to check the the redudancy from the whole database not from the single table.
Can anyone please suggest me, is that really possible or not. If it is possible so what should be the right approach. Thanks in advance.
You should first define what a duplicate is. And for running across multiple DB use can either loop through the databases or you can use EXEC sp_MSforeachdb which is an undocumented sp
Thanks
I exported a couple of entries from a database I have stored locally on my MySQL dbase through PhpMyAdmin and I'd like to replace only those entries on my destination database hosted online. Unfortunately when I try to do so PHPMyAdmin says that those posts already exist and therefore he can't erase them.
It'll take me a lot of time to search for those entries manually within the rest of the posts and delete them one at a time so I was wondering if there's any workaround in order to overwite those entries on import.
Thanks in advance!
A great option is to handle this on your initial export from phpMyAdmin locally. When exporting from phpMyAdmin:
Export method: Custom
Format: SQL
Format-specific options - choose "data" (instead of "structure" or "structure and data")
In Data creation options - Function to use when dumping data: Switch "Insert" to "Update" <-- This is the ticket!
Click Go!
Import into your production database. (always backup your production database before hand just in case)
I know this is an old post, but it actually helped me find a solution built into phpMyAdmin. Hope it helps someone else!
This is a quick and dirty way to do it. Others may have a better solution:
It sounds like you're trying to run INSERT queries, and phpMyAdmin is telling you they already exist. If you use UPDATE queries, you could update the info.
I would copy the queries you have there, into a text editor, preferably one that can handle find and replace, like Notepad++ or Gedit, and then replace some code to change the queries around from INSERT to UPDATE.
See: http://dev.mysql.com/doc/refman/5.0/en/update.html
OR, you could just delete them, then run your INSERT queries.
You might be able to use some logic with find and replace to make a DELETE query that gets rid of them first.
http://dev.mysql.com/doc/refman/5.0/en/delete.html
Check out insert on duplicate. You can either add the syntax to your entries stored locally, or import into a temporary database, then run an INSERT ... SELECT ... ON DUPLICATE KEY UPDATE. If you could post a schema, it would help us guide you better.
In order to monitor mysql table change in django, I have written some codes as follows,
while not find_close_signal():
time.sleep(10)
if MyProject.models.MyModel.objects.all().exists():
some_execution()
However, it doesn't work. If there is no entries in the table at the beginning, then some_execution() will never run even later there are records populated into that table through other out-band ways.
Does anyone ever meet such kind of issue?
I also found in "manage.py shell", this problem happens exactly the same: any other entries added into db out of this shell can not be found in this shell. Is this true or I've made some mistake? Thanks
not sure that this is an issue, but it may be that you have this code executed inside a transaction, so in such a case you can't see any changes.
one more thing is that you can skip ".all()" in this check.
Take a look at my answers here:
Why doesn't this loop display an updated object count every five seconds?
How do I deal with this race condition in django?
You can mark the db as 'dirty' so to make Django discarding cached results:
from django.db import transaction
transaction.set_dirty()
I'm working with MySQL 5.1.39 and Visual Studio 2008 and connecting both with MySQL Connector Net 6.1.2.
What I'd like to do is once a MySqlConnection object is created, be able to handle the "event raised" when a field in a specific row in a given table is updated.
I mean, when that value in that table has been manually changed or modified from any other application, I'd like to receive a signal in my opened VB.NET application. Until now, I do it from opened VB.NET application checking that table every X seconds, but I wonder if it could be done in a better way.
Many thanks for your attention and time.
Ideally, there is the SIGNAL construct, which you can use to field SQL logic errors, but that is not available until MySQL 5.5. It would be best to upgrade to 5.5, if at all possible.
EDIT: There isn't really a good solution for this before 5.5. The TRIGGER works for getting the updates, but not for sending them outside of the database. Be careful, though, as this doesn't work if you're updating through FOREIGN KEY actions, such as CASCADE or UPDATE, as TRIGGERs are not called for these actions. So watch out for that.
DELIMITER $$
CREATE TRIGGER my_trigger_name AFTER UPDATE ON my_table_name
FOR EACH ROW BEGIN
CALL my_on_update_procedure(NEW.entry_name, NEW.whatever_else)
END $$
DELIMITER ;
What my_on_update_procedure does is up to you. Your solution is probably the best bet for 5.1.39 (I would not recommend locking due to scalability issues), but 5.5 would give you the SIGNAL construct, which is exactly what you want (so upgrade!).
I never worked with that but I think "TRIGGER" could be what you're looking for.
http://dev.mysql.com/doc/refman/5.1/en/create-trigger.html
My first thought was to use a database trigger to trigger some sort of notification: message through email, MOM or anything else. Googling didn't turn much up though. I found one approach based on notification through locks: linky. Could be a sane approach...
Oh, and in that blog post they also talk about MySQL UDFs which lets you execute arbitary code when triggers fire. Apparently there is libs to various languages. There is also a duplicate question here on stackoverflow. Cheers