/* *********************************************************************** */
/*========================================================================*/
#include <stdio.h>
#include <string.h>
#include "mysql.h"
/*========================================================================*/
int mysql_exec_sql(MYSQL *mysql,const char *create_definition) { return mysql_real_query(mysql,create_definition,strlen(create_definition));
}
int main(int argc, char **argv) {
MYSQL mysql;
char ccSQL[1000]={0x00};
printf("\n\tMaxito BocaJR \n\t\t micachiquerido.com.ar/lanc/"); printf("\n\t\maxito_de_la_boca@gmail.com\n");
if ( mysql_init(&mysql)==NULL) { printf("\nFailed to initate MySQL connection"); return(1);
}
if (!mysql_real_connect(&mysql,"localhost","root","",NULL,0,NULL,0)) {
printf( "Failed to connect to MySQL: Error: %s\n", mysql_error(&mysql));
return(1);
}
if(mysql_select_db(&mysql,"test")==0)
printf( "Database Selected\n");
else
printf( "Failed to connect to Database: Error: %s\n",
mysql_error(&mysql));
strcat(ccSQL,"CREATE TABLE TDOCUMENTOS ( ");
strcat(ccSQL,"DOC_TIPO SMALLINT NOT NULL, ");
strcat(ccSQL,"DOC_FECUPTE VARCHAR(060) NOT NULL, ");
strcat(ccSQL,"DOC_DESCRIP VARCHAR(060) NOT NULL, ");
strcat(ccSQL,"DOC_ABREVIA CHAR (006) NOT NULL, ");
strcat(ccSQL,"PRIMARY KEY( DOC_TIPO ) )");
printf( "%s\n", ccSQL );
if ( mysql_exec_sql(&mysql,ccSQL )==0)
printf( "Table Created\n");
else
printf( "Failed to create table: Error: %s\n",
mysql_error(&mysql));
mysql_close(&mysql);
}
/*
|-----------------------------------------------------
| "CREATE TABLE TDOCUMENTOS ( "
| "DOC_TIPO SMALLINT NOT NULL, "
| "DOC_FECUPTE VARCHAR(060) NOT NULL, "
| "DOC_DESCRIP VARCHAR(060) NOT NULL, "
| "DOC_ABREVIA CHAR (006) NOT NULL, "
| "PRIMARY KEY( DOC_TIPO ) )"
|-----------------------------------------------------
*/
/* *********************************************************************** */
/*
|==========================================================================
|
|
|
|
|
|
|
|
|==========================================================================
*/
#include <stdio.h>
#include <string.h>
#include "mysql.h"
int mysql_exec_sql(MYSQL *mysql,const char *create_definition) { return mysql_real_query(mysql,create_definition,strlen(create_definition));
}
int main(int argc, char **argv) {
MYSQL mysql;
char ccSQL[1000]={0x00};
printf("\n\tMaxito BocaJR \n\t micachiquerido.com.ar/lanc/"); printf("\n\t\ maxito_de_la_boca@gmail.com\n");
if ( mysql_init(&mysql)==NULL) { printf("\nFailed to initate MySQL connection"); return(1);
}
if (!mysql_real_connect(&mysql,"localhost","root","",NULL,0,NULL,0)) {
printf( "Conexion a MySQL Fallida: Error: %s\n", mysql_error(&mysql));
return(1);
}
if(mysql_select_db(&mysql,"test")==0)
printf( "Database Selected\n");
else
printf( "Conexion MySQL inestable (mysql_select_db): Error: %s\n", mysql_error(&mysql));
strcat(ccSQL,"Alter TABLE TDOCUMENTOS ");
strcat(ccSQL,"MODIFY DOC_FECUPTE VARCHAR(008) NOT NULL");
printf( "%s\n", ccSQL );
if ( mysql_exec_sql(&mysql,ccSQL )==0)
printf( "Table Altered\n");
else
printf( "Failed to connect to edit table: Error: %s\n", mysql_error(&mysql));
mysql_close(&mysql);
}
/*
|-----------------------------------------------------------------
| "CREATE TABLE TDOCUMENTOS ( "
| "DOC_TIPO SMALLINT NOT NULL, "
| "DOC_FECUPTE VARCHAR(060) NOT NULL, "
| "DOC_DESCRIP VARCHAR(060) NOT NULL, "
| "DOC_ABREVIA CHAR (006) NOT NULL, "
| "PRIMARY KEY( DOC_TIPO ) )"
|-----------------------------------------------------------------
| "Alter TABLE TDOCUMENTOS "
| "MODIFY DOC_FECUPTE VARCHAR(008) NOT NULL"
|-----------------------------------------------------------------
*/
/* *********************************************************************** */
/*
|==========================================================================
|
|
|
|
|
|
|
|
|==========================================================================
*/
#include <stdio.h>
#include <string.h>
#include "mysql.h"
int mysql_exec_sql(MYSQL *mysql,const char *create_definition) { return mysql_real_query(mysql,create_definition,strlen(create_definition));
}
int main(int argc, char **argv) {
MYSQL mysql;
char ccSQL[1000]={0x00};
printf("\n\tMaxito BocaJR \n\t micachiquerido.com.ar/"); printf("\n\t\ maxito_de_la_boca@gmail.com\n");
if ( mysql_init(&mysql)==NULL) { printf("\nFailed to initate MySQL connection"); return(1);
}
if (!mysql_real_connect(&mysql,"localhost","root","",NULL,0,NULL,0)) {
printf( "Conexion a MySQL Fallida: Error: %s\n", mysql_error(&mysql));
return(1);
}
if(mysql_select_db(&mysql,"test")==0)
printf( "Database Selected\n");
else
printf( "Conexion MySQL inestable (mysql_select_db): Error: %s\n", mysql_error(&mysql));
strcat(ccSQL,"DROP TABLE TDOCUMENTOS ");
printf( "%s\n", ccSQL );
if ( mysql_exec_sql(&mysql,ccSQL )==0)
printf( "Tabla Eliminada\n");
else
printf( "Failed to connect to edit table: Error: %s\n", mysql_error(&mysql));
mysql_close(&mysql);
}
/*
|-----------------------------------------------------------------
| "CREATE TABLE TDOCUMENTOS ( "
| "DOC_TIPO SMALLINT NOT NULL, "
| "DOC_FECUPTE VARCHAR(060) NOT NULL, "
| "DOC_DESCRIP VARCHAR(060) NOT NULL, "
| "DOC_ABREVIA CHAR (006) NOT NULL, "
| "PRIMARY KEY( DOC_TIPO ) )"
|-----------------------------------------------------------------
| "Alter TABLE TDOCUMENTOS "
| "MODIFY DOC_FECUPTE VARCHAR(008) NOT NULL"
|-----------------------------------------------------------------
| "DROP TABLE TDOCUMENTOS "
|-----------------------------------------------------------------
*/
/* *********************************************************************** */
/*
|==========================================================================
|
|
|
|
|
|
|
|
|==========================================================================
*/
#include <stdio.h>
#include <string.h>
#include "mysql.h"
int mysql_exec_sql(MYSQL *mysql,const char *create_definition) { return mysql_real_query(mysql,create_definition,strlen(create_definition));
}
int main(int argc, char **argv) {
MYSQL mysql;
char ccSQL[1000]={0x00};
printf("\n\tMaxito BocaJR \n\t micachiquerido.com.ar/"); printf("\n\t\ maxito_de_la_boca@gmail.com\n");
if ( mysql_init(&mysql)==NULL) { printf("\nFailed to initate MySQL connection"); return(1);
}
if (!mysql_real_connect(&mysql,"localhost","root","",NULL,0,NULL,0)) {
printf( "Conexion a MySQL Fallida: Error: %s\n", mysql_error(&mysql));
return(1);
}
if(mysql_select_db(&mysql,"test")==0)
printf( "Database Selected\n");
else
printf( "Conexion MySQL inestable (mysql_select_db): Error: %s\n", mysql_error(&mysql));
strcat(ccSQL,"CREATE INDEX DOC_TIPOS ON TDOCUMENTOS( DOC_TIPO )");
printf( "%s\n", ccSQL );
if ( mysql_exec_sql(&mysql,ccSQL )==0)
printf( "Indice creado en forma satisfactoria\n");
else
printf( "Failed to connect to edit table: Error: %s\n", mysql_error(&mysql));
mysql_close(&mysql);
}
/*
|-----------------------------------------------------------------
| "CREATE TABLE TDOCUMENTOS ( "
| "DOC_TIPO SMALLINT NOT NULL, "
| "DOC_FECUPTE VARCHAR(060) NOT NULL, "
| "DOC_DESCRIP VARCHAR(060) NOT NULL, "
| "DOC_ABREVIA CHAR (006) NOT NULL, "
| "PRIMARY KEY( DOC_TIPO ) )"
|-----------------------------------------------------------------
| "Alter TABLE TDOCUMENTOS "
| "MODIFY DOC_FECUPTE VARCHAR(008) NOT NULL"
|-----------------------------------------------------------------
| "DROP TABLE TDOCUMENTOS "
|-----------------------------------------------------------------
| "CREATE INDEX DOC_TIPOS ON TDOCUMENTOS( DOC_TIPO )"
|-----------------------------------------------------------------
*/
/* *********************************************************************** */
/*
|==========================================================================
|
|
|
|
|
|
|
|
|==========================================================================
*/
#include <stdio.h>
#include <string.h>
#include "mysql.h"
int mysql_exec_sql(MYSQL *mysql,const char *create_definition) { return mysql_real_query(mysql,create_definition,strlen(create_definition));
}
int main(int argc, char **argv) {
MYSQL mysql;
char ccSQL[1000]={0x00};
printf("\n\tMaxito BocaJR \n\t micachiquerido.com.ar/"); printf("\n\t\ maxito_de_la_boca@gmail.com\n");
if ( mysql_init(&mysql)==NULL) { printf("\nFailed to initate MySQL connection"); return(1);
}
if (!mysql_real_connect(&mysql,"localhost","root","",NULL,0,NULL,0)) {
printf( "Conexion a MySQL Fallida: Error: %s\n", mysql_error(&mysql));
return(1);
}
if(mysql_select_db(&mysql,"test")==0)
printf( "Database Selected\n");
else
printf( "Conexion MySQL inestable (mysql_select_db): Error: %s\n", mysql_error(&mysql));
strcat(ccSQL,"DROP INDEX DOC_TIPOS ON TDOCUMENTOS ");
printf( "%s\n", ccSQL );
if ( mysql_exec_sql(&mysql,ccSQL )==0)
printf( "Indice eliminado en forma satisfactoria\n");
else
printf( "Failed to connect to edit table: Error: %s\n", mysql_error(&mysql));
mysql_close(&mysql);
}
/*
|-----------------------------------------------------------------
| "CREATE TABLE TDOCUMENTOS ( "
| "DOC_TIPO SMALLINT NOT NULL, "
| "DOC_FECUPTE VARCHAR(060) NOT NULL, "
| "DOC_DESCRIP VARCHAR(060) NOT NULL, "
| "DOC_ABREVIA CHAR (006) NOT NULL, "
| "PRIMARY KEY( DOC_TIPO ) )"
|-----------------------------------------------------------------
| "Alter TABLE TDOCUMENTOS "
| "MODIFY DOC_FECUPTE VARCHAR(008) NOT NULL"
|-----------------------------------------------------------------
| "DROP TABLE TDOCUMENTOS "
|-----------------------------------------------------------------
| "CREATE INDEX DOC_TIPOS ON TDOCUMENTOS( DOC_TIPO )"
|-----------------------------------------------------------------
| "DROP INDEX DOC_TIPOS ON TDOCUMENTOS"
|-----------------------------------------------------------------
*/
/* *********************************************************************** */
/*
|==========================================================================
|
|
|
|
|
|
|
|
|==========================================================================
*/
#include <stdio.h>
#include <string.h>
#include "mysql.h"
int mysql_exec_sql(MYSQL *mysql,const char *create_definition) { return mysql_real_query(mysql,create_definition,strlen(create_definition));
}
int main(int argc, char **argv) {
MYSQL mysql;
char ccSQL[1000]={0x00};
printf("\n\tMaxito BocaJR \n\t micachiquerido.com.ar/"); printf("\n\t\ maxito_de_la_boca@gmail.com\n");
if ( mysql_init(&mysql)==NULL) { printf("\nFailed to initate MySQL connection"); return(1);
}
if (!mysql_real_connect(&mysql,"localhost","root","",NULL,0,NULL,0)) {
printf( "Conexion a MySQL Fallida: Error: %s\n", mysql_error(&mysql));
return(1);
}
if(mysql_select_db(&mysql,"test")==0)
printf( "Database Selected\n");
else
printf( "Conexion MySQL inestable (mysql_select_db): Error: %s\n", mysql_error(&mysql));
strcat(ccSQL,"INSERT INTO TDOCUMENTOS VALUES ( 002,'20190720','CEDULA DE IDENTIDAD','CI')");
printf( "%s\n", ccSQL );
if ( mysql_exec_sql(&mysql,ccSQL )==0)
printf( "INSERT OK!\n");
else
printf( "Failed to connect to edit table: Error: %s\n", mysql_error(&mysql));
mysql_close(&mysql);
}
/*
|-----------------------------------------------------------------
| "CREATE TABLE TDOCUMENTOS ( "
| "DOC_TIPO SMALLINT NOT NULL, "
| "DOC_FECUPTE VARCHAR(060) NOT NULL, "
| "DOC_DESCRIP VARCHAR(060) NOT NULL, "
| "DOC_ABREVIA CHAR (006) NOT NULL, "
| "PRIMARY KEY( DOC_TIPO ) )"
|-----------------------------------------------------------------
| "Alter TABLE TDOCUMENTOS "
| "MODIFY DOC_FECUPTE VARCHAR(008) NOT NULL"
|-----------------------------------------------------------------
| "DROP TABLE TDOCUMENTOS "
|-----------------------------------------------------------------
| "CREATE INDEX DOC_TIPOS ON TDOCUMENTOS( DOC_TIPO )"
|-----------------------------------------------------------------
| "DROP INDEX DOC_TIPOS ON TDOCUMENTOS"
|-----------------------------------------------------------------
| "INSERT INTO TDOCUMENTOS VALUES ( 001,'20190720','DOCUMENTOS NACIONAL DE IDENTIDAD','D.N.I.'"
|-----------------------------------------------------------------
*/
/* *********************************************************************** */
/*
|==========================================================================
|
|
|
|
|
|
|
|
|==========================================================================
*/
#include <stdio.h>
#include <string.h>
#include "mysql.h"
int mysql_exec_sql(MYSQL *mysql,const char *create_definition) { return mysql_real_query(mysql,create_definition,strlen(create_definition));
}
int main(int argc, char **argv) {
MYSQL mysql;
char ccSQL[1000]={0x00};
printf("\n\tMaxito BocaJR \n\t micachiquerido.com.ar/"); printf("\n\t\ maxito_de_la_boca@gmail.com\n");
if ( mysql_init(&mysql)==NULL) { printf("\nFailed to initate MySQL connection"); return(1);
}
if (!mysql_real_connect(&mysql,"localhost","root","",NULL,0,NULL,0)) {
printf( "Conexion a MySQL Fallida: Error: %s\n", mysql_error(&mysql));
return(1);
}
if(mysql_select_db(&mysql,"test")==0)
printf( "Database Selected\n");
else
printf( "Conexion MySQL inestable (mysql_select_db): Error: %s\n", mysql_error(&mysql));
strcat(ccSQL,"DELETE FROM TDOCUMENTOS");
printf( "%s\n", ccSQL );
if ( mysql_exec_sql(&mysql,ccSQL )==0)
printf( "DELETE OK!\n");
else
printf( "Failed to connect to edit table: Error: %s\n", mysql_error(&mysql));
mysql_close(&mysql);
}
/*
|-----------------------------------------------------------------
| "CREATE TABLE TDOCUMENTOS ( "
| "DOC_TIPO SMALLINT NOT NULL, "
| "DOC_FECUPTE VARCHAR(060) NOT NULL, "
| "DOC_DESCRIP VARCHAR(060) NOT NULL, "
| "DOC_ABREVIA CHAR (006) NOT NULL, "
| "PRIMARY KEY( DOC_TIPO ) )"
|-----------------------------------------------------------------
| "Alter TABLE TDOCUMENTOS "
| "MODIFY DOC_FECUPTE VARCHAR(008) NOT NULL"
|-----------------------------------------------------------------
| "DROP TABLE TDOCUMENTOS "
|-----------------------------------------------------------------
| "CREATE INDEX DOC_TIPOS ON TDOCUMENTOS( DOC_TIPO )"
|-----------------------------------------------------------------
| "DROP INDEX DOC_TIPOS ON TDOCUMENTOS"
|-----------------------------------------------------------------
| "INSERT INTO TDOCUMENTOS VALUES ( 001,'20190720','DOCUMENTOS NACIONAL DE IDENTIDAD','D.N.I.'"
|-----------------------------------------------------------------
*/
/* *********************************************************************** */
/*
|==========================================================================
|
|
|
|
|
|
|
|
|==========================================================================
*/
#include <stdio.h>
#include <string.h>
#include "mysql.h"
int main( int argc, char *argv[] ) {
MYSQL *conn; /* variable de conexión para MySQL */
MYSQL_RES *res; /* variable que contendra el resultado de la consuta */
MYSQL_ROW row; /* variable que contendra los campos por cada registro consultado */
char *server = "localhost"; /* direccion del servidor 127.0.0.1, localhost o direccion ip */
char *user = "root"; /* usuario para consultar la base de datos */
char *password = ""; /* contraseña para el usuario en cuestion */
char *database = "dbcalabresa"; /* nombre de la base de datos a consultar */
conn = mysql_init(NULL); /* inicializacion a nula la conexión */
/* conectar a la base de datos */
if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) { /* definir los parámetros de la conexión antes establecidos */
fprintf(stderr, "%s\n", mysql_error(conn)); /* si hay un error definir cual fue dicho error */
printf("hay un error al conectar MariaDB \n"); return(-1);
}
/* enviar consulta SQL */
if (mysql_query(conn, "select * from TDOCUMENTOS")) { /* definicion de la consulta y el origen de la conexion */
fprintf(stderr, "%s\n", mysql_error(conn));
return(-1);
}
res = mysql_use_result(conn);
printf("DOC_TIPO\tDOC_FECUPTE\t\tDOC_DESCRIP\n"); while ((row = mysql_fetch_row(res)) != NULL)
/* recorrer la variable res con todos los registros obtenidos para su uso */
printf("%s\t%s\t%s \n", row[0],row[1 ],row[2]); /* la variable row se convierte en un arreglo por el numero de campos que hay en la tabla */
/* se libera la variable res y se cierra la conexión */
mysql_free_result(res);
mysql_close(conn);
}
/*
|-----------------------------------------------------------------
| "CREATE TABLE TDOCUMENTOS ( "
| "DOC_TIPO SMALLINT NOT NULL, "
| "DOC_FECUPTE VARCHAR(060) NOT NULL, "
| "DOC_DESCRIP VARCHAR(060) NOT NULL, "
| "DOC_ABREVIA CHAR (006) NOT NULL, "
| "PRIMARY KEY( DOC_TIPO ) )"
|-----------------------------------------------------------------
| "Alter TABLE TDOCUMENTOS "
| "MODIFY DOC_FECUPTE VARCHAR(008) NOT NULL"
|-----------------------------------------------------------------
| "DROP TABLE TDOCUMENTOS "
|-----------------------------------------------------------------
| "CREATE INDEX DOC_TIPOS ON TDOCUMENTOS( DOC_TIPO )"
|-----------------------------------------------------------------
| "DROP INDEX DOC_TIPOS ON TDOCUMENTOS"
|-----------------------------------------------------------------
| "INSERT INTO TDOCUMENTOS VALUES ( 001,'20190720','DOCUMENTOS NACIONAL DE IDENTIDAD','D.N.I.'"
|-----------------------------------------------------------------
| "SELECT DOC_TIPO, DOC_DESCRIP, DOC_ABREVIA FROM TDOCUMENTOS"
|-----------------------------------------------------------------
*/
/* *********************************************************************** */
/* *********************************************************************** */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main( int argc, char *argv[] ) {
FILE* archivo = fopen("centrale.txt","r"); char * buffer = NULL;
char ccH[12] = {0X00}; char ccB[12] = {0X00}; char ccU[12] = {0X00}; char ccP[12] = {0X00};
int i, c;
int j = 0;
int inPos = 0;
c = fgetc(archivo);
while(!feof(archivo)) { buffer = (char*)realloc(NULL, sizeof(char));
i = 0;
while( c != '\n') {
if ( c == '=') { /* printf("Position: %i\n", i); */ inPos = i + 1 ;
}
buffer[i] = c;
i++;
buffer = (char*)realloc(buffer, (i+1)*sizeof(char));
c = fgetc(archivo);
}
/*===========================*/
/* */
/* Agrego el \n al buffer */
/* */
/*===========================*/
buffer = (char*)realloc(buffer, (i+2)*sizeof(char));
buffer[i] = c;
buffer[i+1] = 0;
/*===========================*/
/* */
/* Trabajar con el buffer */
/* */
/*===========================*/
j++;
if (inPos>0) { switch(j) { case 1:
strcat( ccH, &buffer[inPos] );
break;
case 2:
strcat( ccB, &buffer[inPos]);
break;
case 3:
strcat( ccU, &buffer[inPos]);
break;
case 4:
strcat( ccP, &buffer[inPos] );
break;
default :
printf("\n"); break;
}
}
printf("%s", buffer); free(buffer);
c = fgetc(archivo);
}
fclose(archivo);
printf("Hostname===> : %s", ccH); printf("Basename===> : %s", ccB); printf("Username===> : %s", ccU); printf("Password===> : %s", ccP); return 0;
}
/* *********************************************************************** */
/* *********************************************************************** */
#include <stdio.h>
#include <stdlib.h>
int main( int argc, char *argv ) {
FILE* archivo = fopen("centrale.txt","r"); char * buffer = NULL;
int i, c, j;
c = fgetc(archivo);
while(!feof(archivo)) { buffer = (char*)realloc(NULL, sizeof(char));
i = 0;
while( c != '\n') {
if ( c == '=') { printf("Position: %i\n", i); inPos = i + 1 ;
}
buffer[i] = c;
i++;
buffer = (char*)realloc(buffer, (i+1)*sizeof(char));
c = fgetc(archivo);
}
j++;
if (inPos>0) { switch()
ccValor
}
/*Agrego el \n al buffer*/
buffer = (char*)realloc(buffer, (i+2)*sizeof(char));
buffer[i] = c;
buffer[i+1] = 0;
/*Trabajar con el buffer*/
printf("%s", buffer); free(buffer);
c = fgetc(archivo);
}
close(archivo);
return 0;
}
/* *********************************************************************** */