From 7f6c6e6db75530695d85760a3e268aa26b2c0ed6 Mon Sep 17 00:00:00 2001 From: marcin Date: Fri, 19 Apr 2019 16:39:15 +0200 Subject: [PATCH] initial commit --- mysql_python/mysql_connect.py | 34 ++++++++++++++++++ postres_cpp/a.out | Bin 0 -> 66568 bytes postres_cpp/posgres_connector.cpp | 57 ++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 mysql_python/mysql_connect.py create mode 100755 postres_cpp/a.out create mode 100644 postres_cpp/posgres_connector.cpp diff --git a/mysql_python/mysql_connect.py b/mysql_python/mysql_connect.py new file mode 100644 index 0000000..73213c6 --- /dev/null +++ b/mysql_python/mysql_connect.py @@ -0,0 +1,34 @@ +import mysql.connector +import getpass + +HOST="localhost" +DATABASE="Fabryka_Sprzetu_IT" +SQL=("SELECT * FROM Produkt;") + + +print("Welcome to MySQL connector. \nYou are trying to connect to host: " + HOST + "\nType your credentials to connect:") + +while(True): + print("User: ", end='') + user=input() + password=getpass.getpass() + print() + try: + sqlDatabase = mysql.connector.connect(host=HOST, user=user, passwd=password, database=DATABASE) + break + except mysql.connector.Error as e: + print(e) + if e.errno!=1045: + exit() + else: + print("Try again.\n") + + +curs=sqlDatabase.cursor() +print(SQL) +curs.execute(SQL) +res=curs.fetchall() + +for r in res: + print(r) + diff --git a/postres_cpp/a.out b/postres_cpp/a.out new file mode 100755 index 0000000000000000000000000000000000000000..525fce7bbcd65a7bd63ee8e6a6b0884d721fb9e2 GIT binary patch literal 66568 zcmeHw4}4VBmH!J#Fe3l7XeqKfB3k?xGa-TCza}Ar6ATcOfJo8DWM&|vlT4gUFi^E| z0hfqrDXT8E{&uNlyKL9BtV=0tU5&~bYF&%AtF&61wdhWSwrN)_wbuN;=iYPY-Ffrg zBw!GKzmHGJdH0-i&pr3tbI<+r?tAlPU(LKxIXSroU%AFrMh@;*oGTIKjQ4-QHvr{E znQ;pKo^70Ej7B<7;3U0V0#N1EG%6hyFrEsed^?zKhf|qPLDGpXf|Sqg^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xVbB}GB?yL^hD&7qRUHr!EuWq(6CEW;~_s9nl_3bg|_ zdj4|!?jv0aPFD>l(HZ@3H}HD?CUR(83VPU|B-Uy_mF~ffo_`}bBrXNj@1RL+X8XMa z!g%~s&D3|BMk|tN3*?a5fc1h5-r;xQbRvsQ#*QRr*xi RIOX^JNpeiHWw0fU{|gC@C!qiU literal 0 HcmV?d00001 diff --git a/postres_cpp/posgres_connector.cpp b/postres_cpp/posgres_connector.cpp new file mode 100644 index 0000000..f7ae29e --- /dev/null +++ b/postres_cpp/posgres_connector.cpp @@ -0,0 +1,57 @@ +#include +#include +#include +#include +#include + +#define HOST "127.0.0.1" +#define DATABASE "fabryka_sprzetu_it" +#define SQL "SELECT * FROM PC;" + +#define COL_W 15 //if some table contetnts have too much characters/numbers in it, change this value. + +using namespace std; +using namespace pqxx; + +int main() { + //welcome message & prompt + cout << "Welcome to MySQL connector. \nYou are trying to connect to host: " << HOST << "\nType your credentials to connect:\n"; + string username, password; + cout << "User: "; + cin >> username; + cout << "Password: "; + cin >> password; + + //prases the text to match the connection typedef input arg + stringstream stream; + stream << "dbname = " << DATABASE << " user = " << username << " password = " << password << " \ + hostaddr = " << HOST << " port = 5432"; + + try { + connection C(stream.str()); + if (!C.is_open()) return 1; //closes the program if there's an issue with connection + + nontransaction N(C); + result R(N.exec(SQL)); + + //print result of last used query + cout << SQL << endl; + + //print column names + for(int i=0; i<(int)R[0].size(); i++) + cout << right << setw(COL_W) << R.column_name(i); + cout << endl; + //print table contents + for (result::const_iterator r = R.begin(); r!=R.end(); r++){ + for(int i=0; i<(int)R[0].size(); i++) + cout << right << setw(COL_W) << r[i].as(); + cout << endl; + } + + //end connection + C.disconnect(); + } catch (const exception &e) { + cerr << e.what() << std::endl; + return 1; + } +} \ No newline at end of file