Headers for functions

Database
L101Danzan 2024-02-13 14:06:29 +02:00
parent 5201824c7d
commit d240a1c0fe
9 changed files with 33 additions and 31 deletions

View File

0
ToToCinema/AT.h 100644
View File

11
ToToCinema/DD.cpp 100644
View File

@ -0,0 +1,11 @@
//#include <iostream>
//#include <string>
//#include "DD.h"
//using namespace std;
//
//int main() {
// string database = "mongodb+srv://Danzan:<password>@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority";
// database = getDatabaseLink(database);
// cout << database;
// return 0;
//}

17
ToToCinema/DD.h 100644
View File

@ -0,0 +1,17 @@
#include <iostream>
#include <string>
#include "config.h"
using namespace std;
string getDatabaseLink(string database) {
string password = get_password();
cout << password << endl;
try {
database.replace(21, 10, password);
}
catch (...) {
cout << "Error finding password\n";
}
return database;
}

View File

0
ToToCinema/EN.h 100644
View File

View File

@ -1,38 +1,12 @@
#include <iostream>
#include <string>
#include "config.h"
#include <bsoncxx/json.hpp>
#include <mongocxx/client.hpp>
#include <mongocxx/instance.hpp>
#include "DD.h"
using namespace std;
string password = db_password;
int main() {
string database = "mongodb+srv://Danzan:<password>@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority";
database.replace(21, 10, password);
cout << database;
try
{
// Create an instance.
mongocxx::instance inst{};
const auto uri = mongocxx::uri{ "mongodb+srv://Danzan:<password>@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority" };
// Set the version of the Stable API on the client
mongocxx::options::client client_options;
const auto api = mongocxx::options::server_api{ mongocxx::options::server_api::version::k_version_1 };
client_options.server_api_opts(api);
// Setup the connection and get a handle on the "admin" database.
mongocxx::client conn{ uri, client_options };
mongocxx::database db = conn["admin"];
// Ping the database.
const auto ping_cmd = bsoncxx::builder::basic::make_document(bsoncxx::builder::basic::kvp("ping", 1));
db.run_command(ping_cmd.view());
std::cout << "Pinged your deployment. You successfully connected to MongoDB!" << std::endl;
}
catch (const std::exception& e)
{
// Handle errors
std::cout << "Exception: " << e.what() << std::endl;
//}
string database = "mongodb+srv://Danzan:<password>@testandlearnserverclust.54zdaqv.mongodb.net/?retryWrites=true&w=majority";
database = getDatabaseLink(database);
cout << database;
return 0;
}

View File

0
ToToCinema/VE.h 100644
View File