Advertisement
Guest User

Untitled

a guest
Apr 11th, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using MySql.Data;
  7. using MySql.Data.Entity;
  8. using MySql.Data.MySqlClient;
  9. using System.Globalization;
  10.  
  11. namespace MYSQL {
  12.     class Program {
  13.         static void Main(string[] args) {
  14.             string connectionString =
  15.                 "SERVER=LOCALHOST;DATABASE=secret_stash;USER=root;PASSWORD=secure";
  16.             MySqlConnection conn = new MySqlConnection(connectionString);
  17.             conn.Open();
  18.             MySqlCommand test;
  19.             MySqlDataReader reader;
  20.             int id = 1;
  21.             object gameName = "";
  22.             object game = "";
  23.  
  24.             #region Hide
  25.             List<string> FirstNames = new List<string>()
  26.     {
  27.         "Sergio",
  28.         "Daniel",
  29.         "Carolina",
  30.         "David",
  31.         "Reina",
  32.         "Saul",
  33.         "Bernard",
  34.         "Danny",
  35.         "Dimas",
  36.         "Yuri",
  37.         "Ivan",
  38.         "Laura"
  39.     };
  40.  
  41.             List<string> LastNamesA = new List<string>()
  42.             {
  43.         "Tapia",
  44.         "Gutierrez",
  45.         "Rueda",
  46.         "Galviz",
  47.         "Yuli",
  48.         "Rivera",
  49.         "Mamami",
  50.         "Saucedo",
  51.         "Dominguez",
  52.         "Escobar",
  53.         "Martin",
  54.         "Crespo",
  55.         "Johnson",
  56.         "Williams",
  57.         "Jones",
  58.         "Brown",
  59.         "David",
  60.         "Miller",
  61.         "Wilson",
  62.         "Anderson",
  63.         "Thomas",
  64.         "Jackson",
  65.         "White",
  66.         "Robinson"
  67.     };
  68.  
  69.             List<string> LastNamesB = new List<string>()
  70.             {
  71.         "Johnson",
  72.         "Williams",
  73.         "Jones",
  74.         "Brown",
  75.         "David",
  76.         "Miller",
  77.         "Wilson",
  78.         "Anderson",
  79.         "Thomas",
  80.         "Jackson",
  81.         "White",
  82.         "Robinson"
  83.     };
  84.  
  85.             var permutations = new List<Tuple<int, int, int>>();
  86.             List<string> generatedNames = new List<string>();
  87.  
  88.             Random random = new Random();
  89.             int a, b, c;
  90.  
  91.             //We want to generate 500 names.
  92.             while (permutations.Count < 500) {
  93.                 a = random.Next(0, FirstNames.Count);
  94.                 b = random.Next(0, FirstNames.Count);
  95.                 c = random.Next(0, FirstNames.Count);
  96.  
  97.                 Tuple<int, int, int> tuple = new Tuple<int, int, int>(a, b, c);
  98.  
  99.                 if (!permutations.Contains(tuple)) {
  100.                     permutations.Add(tuple);
  101.                 }
  102.             }
  103.  
  104.             List<string> countries = new List<string>();
  105.             countries.Add("Swedish");
  106.             countries.Add("Danish");
  107.             countries.Add("German");
  108.             countries.Add("Bolivian");
  109.             countries.Add("Armenian");
  110.             countries.Add("Space");
  111.             countries.Add("Finnish");
  112.             countries.Add("Russian");
  113.             countries.Add("USSR");
  114.             countries.Add("African-American");
  115.  
  116.             List<string> jobs = new List<string>();
  117.             jobs.Add("Sausage-Seller");
  118.             jobs.Add("Programmer");
  119.             jobs.Add("Filmmaker");
  120.             jobs.Add("Bum");
  121.             jobs.Add("Scientist");
  122.             jobs.Add("Spaceman");
  123.             jobs.Add("Failure");
  124.             jobs.Add("Teacher");
  125.             jobs.Add("Clown");
  126.             jobs.Add("King");
  127.  
  128.             foreach (var tuple in permutations) {
  129.                 test = new MySqlCommand("INSERT INTO person (first_name, last_name, birthyear, occupation, nationality, salary) VALUES('" + FirstNames[tuple.Item1] + "', '" + LastNamesA[tuple.Item2] + "', " + random.Next(1,2016) + ", '" + jobs[random.Next(jobs.Count )] + "', '" + countries[random.Next(countries.Count)] + "', " + random.Next(500000) + ")",conn);
  130.                 reader = test.ExecuteReader();
  131.                 reader.Close();
  132.                 generatedNames.Add(string.Format("{0} {1} {2}", FirstNames[tuple.Item1],
  133.                                                                 LastNamesA[tuple.Item2],
  134.                                                                 LastNamesB[tuple.Item3])
  135.                 );
  136.             }
  137.  
  138.             foreach (var n in generatedNames) {
  139.                
  140.             }
  141.             #endregion
  142.            
  143.  
  144.  
  145.             //test = new MySqlCommand("create Table Games ( id int AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255));", conn);
  146.             //test = new MySqlCommand("UPDATE `basketball_played` SET `team_2_score` = '1' WHERE `basketball_played`.`game_id` = 2;",conn);
  147.             /*test = new MySqlCommand("select name from games where id = " + id, conn);
  148.             reader = test.ExecuteReader();
  149.             while (reader.Read()) { gameName = reader[0]; }
  150.             reader.Close();
  151.  
  152.             test = new MySqlCommand("select corresponding_column from games where name = '" + gameName + "'",conn); ;
  153.             reader = test.ExecuteReader();
  154.             while (reader.Read()) { game = reader[0]; }
  155.             reader.Close();
  156.  
  157.             test = new MySqlCommand("select team_1 from " + game + " where team_1_score = 2", conn);
  158.             test = new MySqlCommand("ALTER TABLE Games ADD Played_Games int default '5'", conn);
  159.             reader = test.ExecuteReader();
  160.             while (reader.Read()) { game = reader[0]; }
  161.             reader.Close();
  162.  
  163.             Console.WriteLine("The " + gameName + "team, " + game + ", played in a game and scored 2 points");*/
  164.            
  165.             conn.Close();
  166.         }
  167.     }
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement