Tags: MySQL

Sort by: Date / Title /

  1. 1 week ago by macks
    1. from django.db import load_backend, transaction, connection
    2.  
    3. #manipular datos de una bd externa
    4.  
    5. def sincronizeDB(self):
    6.         myBackend = load_backend('mysql') # or 'mysql', 'sqlite3', 'oracle'
    7.         myConnection = myBackend.DatabaseWrapper({
    8.             'DATABASE_HOST': '192.168.1.11',
    9.             'DATABASE_NAME': 'agenciaperu_local',
    10.             'DATABASE_OPTIONS': {},
    11.             'DATABASE_PASSWORD': "",
    12.             'DATABASE_PORT': "",
    13.             'DATABASE_USER': "root",})
    14.         # Now we can do all the standard raw sql stuff with myConnection.
    15.         myCursor = myConnection.cursor()       
    16.         id = 22
    17.         name = "tecnologia para jos"
    18.         slug = "tecnologia_para_jos"
    19.         row = myCursor.execute("INSERT INTO category(name, slug )  values(%s,%s);", [name, slug])
    20.         row = myConnection._commit()
    21.         #row = transaction.rollback_unless_managed()  -----> sería cuando trabajamos en local
    22.  
    23. # select simple
    24.         #row = myCursor.execute("select *from category where id = %s and highlight = %s;",[id,0])
    25.         myCursor.fetchall()
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2056"></script>
  2. 6 months ago by macks
    1. #terminal
    2. C:\>mysql -uroot -p
    3. mysql> SELECT version();
    4.  
    5. # cliente mysql
    6. SELECT version();
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1787"></script>
  3. 6 months ago by macks
    agregar una columna despues de otra
    1. ALTER TABLE media add COLUMN  status VARCHAR (20) after component
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1780"></script>
  4. sponsorised links
  5. 7 months ago by macks
    1. #dump
    2. mysqldump -hlocalhost -uuser -ppassword nomdatabase> nomdatabase.sql
    3.  
    4. #restore
    5. mysql -hlocalhost -uuser -ppassword nomdatabase < nomdatabase
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1775"></script>
  6. 7 months ago by macks
    a partir de mysql 5.0
    1. SELECT TIMESTAMPDIFF(DAY,'2005-01-02','2006-01-08');
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1772"></script>
  7. 7 months ago by benoitbalon
    1. mysqldump -h localhost -u user -ppassword -r/tmp/mysql_backup.data nomdatabase
    2.  
    3. mysql -h localhost -u user -ppassword nomdatabase < /tmp/mysql_backup.data
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1761"></script>
  8. 10 months ago by cyo
    1. mysql -u root -p
    2. mysql> show databases;
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1693"></script>
  9. 10 months ago by cyo
    1. mysql -u root -p -D nom_de_la_base
    2. mysql> status;
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1692"></script>
  10. 1 year ago by spirit
    Great circle distance
    Great circle distance
    Find the distance in kilometres between two points on the surface of the earth. This is just the sort of problem stored functions were made for. For a first order approximation, ignore deviations of the earth's surface from the perfectly spherical. Then the distance in radians is given by a number of trigonometric formulas. ACOS and COS behave reasonably:
    
                 COS(lat1-lat2)*(1+COS(lon1-lon2)) - COS(lat1+lat2)*(1-COS(lon1-lon2))
    rads = ACOS( --------------------------------------------------------------------- )
                                                  2
    
    We need to convert degrees latitude and longitude to radians, and we need to know the length in km of one radian on the earth's surface, which is 6378.388. The function:
    
    set log_bin_trust_function_creators=TRUE;
    
    DROP FUNCTION IF EXISTS GeoDistKM;
    DELIMITER |
    CREATE FUNCTION GeoDistKM( lat1 FLOAT, lon1 FLOAT, lat2 FLOAT, lon2 FLOAT ) RETURNS float
    BEGIN
      DECLARE pi, q1, q2, q3 FLOAT;
      DECLARE rads FLOAT DEFAULT 0;
      SET pi = PI();
      SET lat1 = lat1 * pi / 180;
      SET lon1 = lon1 * pi / 180;
      SET lat2 = lat2 * pi / 180;
      SET lon2 = lon2 * pi / 180;
      SET q1 = COS(lon1-lon2);
      SET q2 = COS(lat1-lat2);
      SET q3 = COS(lat1+lat2);
      SET rads = ACOS( 0.5*((1.0+q1)*q2 - (1.0-q1)*q3) ); 
      RETURN 6378.388 * rads;
    END;
    |
    DELIMITER ;
    
    -- toronto to montreal (505km):
    select geodistkm(43.6667,-79.4167,45.5000,-73.5833);
    +----------------------------------------------+
    | geodistkm(43.6667,-79.4167,45.5000,-73.5833) |
    +----------------------------------------------+
    |                           505.38836669921875 |
    +----------------------------------------------+
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1555"></script>
  11. 1 year ago by jacinmontava
    1. <?php
    2.  
    3. $dbhost = "servidor"; $dbuser = "usuario"; $dbpassword = "clave"; $dbname = "base_de_datos";
    4. mysql_connect($dbhost,$dbuser,$dbpassword);
    5. $tablas = mysql_list_tables($dbname);
    6.  
    7. while (list($tabla) = mysql_fetch_row($tablas)) {
    8. echo $tabla."<br />";
    9. } ?>
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/1378"></script>

First / Previous / Next / Last / Page 1 of 5 (43 posteets)