Advertisement
Guest User

Untitled

a guest
Mar 18th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.05 KB | None | 0 0
  1. //PRZYKŁADOWE LOGOWANIE
  2.     char logData[150]="host=localhost port=5432 dbname=projekt user=dlipinski password=";
  3.     char pass[30]={'\0'};
  4.     printf("Password: ");
  5.     system("stty -echo");
  6.     scanf("%s",&pass);
  7.     system("stty echo");
  8.     system("clear");
  9.     strcpy(passT,pass);
  10.     strcat(logData,pass);
  11.   PGconn *conn = PQconnectdb(logData);
  12.  
  13. //PRZYKŁADOWE KLEJENIE KOMEND
  14. //----------------------------------------DROP
  15.     char dropTable[200]={'\0'};
  16.     strcat(dropTable,"DROP TABLE ");
  17.     strcat(dropTable, tableName);
  18.     strcat(dropTable, ";");
  19.     doSQL(conn, dropTable);
  20.     strcat(tableId,"id_");
  21.     strcat(tableId,tableName);
  22. //----------------------------------------CREATE
  23.     char createTable[200]={'\0'};
  24.     strcat(createTable,"CREATE TABLE ");
  25.     strcat(createTable, tableName);
  26.     strcat(createTable, "(");
  27.     strcat(createTable, tableId);
  28.     strcat(createTable," SERIAL PRIMARY KEY ");
  29.     for(i=0;i<counter;i++){
  30.         strcat(createTable,", ");
  31.         strcat(createTable,columnNames[i]);
  32.         strcat(createTable," VARCHAR");
  33.     }
  34.     strcat(createTable,");");
  35.     doSQL(conn, createTable);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement