Jump to content
UBot Underground

So I'm building my 1st bot using the mysql plugins


Recommended Posts

and I'm stuck....

 

I guess I don't really understand how the 'query with results' works.  If it's putting data into a table, then what's the query I would use to return two values into one row on the table?

 

Here's what I need to do:  I have a table with over 16k rows.  I need to loop through each row and if a row DOES NOT have certain values, then it does the action I want.  I'm not really sure how to word this, so here's an example:

 

Name  |  State  |  Email

Eric  |  California  |  eric@gmail.com

Johnny Depp  |  Oregon  |  dsflkjl@yahoo.com

Marry  |  New York  |  marry@hotmail.com

 

If a row contains 'gmail.com' or 'johnny' then I DO NOT send an email.  Otherwise, I send an email.  Therefore, the person I email is Marry.

 

Any ideas?

 

PS. I have been googling how to do mysql queries because I'm new to this and I came across http://stackoverflow.com/questions/4153290/query-to-get-the-value-of-a-particular-cell-in-mysql but that's not working at all.  I'm not sure how this is supposed to work in ubot.

 

PSS.  I guess I should point out that I only care about two columns for when I'm deciding whether or not to email.  I only care about the email and name colums.  That's why towards the beginning of my post I asked about entering data from two cells into the table.

Link to post
Share on other sites

SELECT column_name,column_name
FROM table_name;
http://www.w3schools.com/sql/sql_select.asp

 

I would just dump the results immediately to a table in ubot, and deal with sorting via ubot.

 

You can try using wild cards if you really want to try and limit your results before they make it into ubot.

 

http://www.w3schools.com/sql/sql_wildcards.asp

 

So something like

SELECT * FROM 'your table' WHERE Email LIKE '%[!@gmail]%' WHERE Name LIKE '%[!johnny]%';

I *think* will select all rows where the email isn't a gmail account and the name is not johnny. I haven't written straight mysql for a while though. 
Link to post
Share on other sites

Actually, it is much better to get results already sorted by SQL, especially when dealing with large lists/tables...

Link to post
Share on other sites

I have reproduced your querry,creating the db from scratch ,and sending to table(&whomtosendemail)

just the results you need :

plugin command("DatabaseCommands.dll", "connect to database", "server=localhost;uid=yourroot; pwd=yourpassword; database=mysql; port=3306; pooling=false") {
    plugin command("DatabaseCommands.dll", "query", "CREATE DATABASE IF NOT EXISTS userdata")
    plugin command("DatabaseCommands.dll", "query", "CREATE TABLE IF NOT EXISTS userdata.myuserdata (
`Name` VARCHAR( 55 ) NOT NULL ,
`State` VARCHAR( 55 ) NOT NULL ,
`Email` VARCHAR( 55 ) NOT NULL
) ENGINE = MYISAM")
    plugin command("DatabaseCommands.dll", "query", "INSERT INTO userdata.myuserdata (Name, State, Email) VALUES (\'Eric\', \'California\', \'eric@gmail.com\');
INSERT INTO userdata.myuserdata (Name, State, Email) VALUES (\'Johnny Depp\', \'Oregon\', \'dsflkjl@yahoo.com\');
INSERT INTO userdata.myuserdata (Name, State, Email) VALUES (\'Marry\', \'New York\', \'marry@hotmail.com\');")
    plugin command("DatabaseCommands.dll", "query with results", "SELECT * 
FROM  userdata.myuserdata 
WHERE Name NOT LIKE  \'%Johnny%\'
AND Email NOT LIKE  \'%@gmail.com%\';", &whomtosendemail)
}

Link to post
Share on other sites

Actually, it is much better to get results already sorted by SQL, especially when dealing with large lists/tables...

I've gone both ways with it. Sorting from sql is faster since it's optimized for it. That would be the best practice. Only reason not to is if you're spending too much time trying to write the query. Easier to revisit when  everything is done. 

Link to post
Share on other sites

Only reason not to is if you're spending too much time trying to write the query. Easier to revisit when  everything is done.

 

Personally, I think that the time spent learning how to build the proper queries gets less and less taxing, the more of them you build and in the end, pays back a hefty ROI and satisfaction of things done right.

 

However, I know what you mean; especially when on a deadline, could be better to just DO it (the shotgun vs. laser approach)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...