Skip to content

Commit

Permalink
Formating
Browse files Browse the repository at this point in the history
  • Loading branch information
Malkverbena committed Jan 19, 2023
1 parent 4b89ce1 commit 3efb496
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
15 changes: 10 additions & 5 deletions SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
# DO NOT FORGET TO REPLACE THE SLASH FOR BACKSLASH ON PATHS => "\" FOR "/"

# Enter with path to Boost library here
boost_path = "C:/boost_1_76_0"
# boost_path = "C:/boost_1_76_0"
boost_path = "/media/cleber/686A6A516A6A1BD6/boost_1_76_0"


# Enter with the path to jdbc here (mysql_connection.h & mysql_driver.h)
include_path = "C:/mysql/mysql-connector-c++-8.0.29-winx64/include/jdbc"
# include_path = "C:/mysql/mysql-connector-c++-8.0.29-winx64/include/jdbc"
include_path = "/media/cleber/686A6A516A6A1BD6/mysql/mysql-connector-c++-8.0.29-winx64/include/jdbc"

# Enter with the path to mysql libs here (mysqlcppconn.lib)
lib_path = 'C:/mysql/mysql-connector-c++-8.0.29-winx64/lib64/vs14/debug'

# Enter with the path to mysql libs here (mysqlcppconn.lib)
# lib_path = 'C:/mysql/mysql-connector-c++-8.0.29-winx64/lib64/vs14/debug'
lib_path = "/media/cleber/686A6A516A6A1BD6/mysql/mysql-connector-c++-8.0.29-winx64/lib64/vs14/debug"

# Enable the module debug.
module_debug = True
Expand Down Expand Up @@ -77,7 +81,8 @@ if env["platform"] in ["windows", "UWP"]:
sufix = sufix[0:-3]

mysql_env.Append(CPPFLAGS =["-I" + include_path, "-L " + lib_path])
target_lib_arr = [target_lib] # TODO: More libs are expected for static compilling (ssl, crypto e etc...)
# TODO: More libs are expected for static compilling (ssl, crypto e etc...)
target_lib_arr = [target_lib]

# copy libs
for i in target_lib_arr:
Expand Down
26 changes: 19 additions & 7 deletions mysql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Array MySQL::_query(String p_sqlquery, Array p_values, DataFormat data_model, bo

else{
// This module can't recognize this format.
ERR_FAIL_V_EDMSG( Array(), "Format not supoeted!");
ERR_FAIL_V_EDMSG( Array(), "Format not supported!");
}
// FITTING DATA -------- END

Expand All @@ -326,7 +326,7 @@ Array MySQL::_query(String p_sqlquery, Array p_values, DataFormat data_model, bo

} // WHILE

} // try
} // TRY

catch (sql::SQLException &e) {
print_SQLException(e);
Expand Down Expand Up @@ -698,7 +698,7 @@ Variant MySQL::get_property(String p_property){

ERR_FAIL_COND_V_EDMSG( prop_type == INVALID, ret, "The property '" + p_property.to_upper() + "' does not exist!");

// Colocar no doc
// TODO: Put it on docs
// "Non-existent property. \nFor more information visit: \nhttps://dev.mysql.com/doc/connector-cpp/1.1/en/connector-cpp-connect-options.html"
map <sql::SQLString, sql::Variant>::iterator _prop;
_prop = connection_properties.find( property );
Expand Down Expand Up @@ -805,8 +805,10 @@ MySQL::ConnectionStatus MySQL::connection_status() {


Dictionary MySQL::get_connection_metadata(){
ERR_FAIL_COND_V_MSG(connection_status() != CONNECTED, Dictionary(), "DatabaseMetaData FAILURE - database is not connected! - METHOD: get_connection_metadata");

Dictionary ret;
ERR_FAIL_COND_V_MSG(connection_status() != CONNECTED, ret, "DatabaseMetaData FAILURE - database is not connected! - METHOD: get_connection_metadata");

sql::DatabaseMetaData *dbcon_meta = conn->getMetaData();
std::unique_ptr < sql::ResultSet > res(dbcon_meta->getSchemas());
ret["Total number of schemas"] = res->rowsCount();
Expand All @@ -831,6 +833,7 @@ Dictionary MySQL::get_connection_metadata(){
ret["Maximum Columns per Table"] = dbcon_meta->getMaxColumnsInTable();
ret["Maximum Columns per Index"] = dbcon_meta->getMaxColumnsInIndex();
ret["Maximum Row Size per Table"] = dbcon_meta->getMaxRowSize();

return ret;
}

Expand Down Expand Up @@ -1039,6 +1042,7 @@ void MySQL::_fit_statement(std::shared_ptr<sql::PreparedStatement> prep_stmt, st

void MySQL::print_SQLException(sql::SQLException &e) {
/*
// NOTE:
If (e.getErrorCode() == 1047) = Your server does not seem to support Prepared Statements at all. Perhaps MYSQL < 4.1?.
Error: 1047 SQLSTATE: 08S01 (ER_UNKNOWN_COM_ERROR)
Message: Unknown command
Expand All @@ -1058,9 +1062,10 @@ void MySQL::print_SQLException(sql::SQLException &e) {
_last_sql_error["MySQL error code"] = errCode;
_last_sql_error["SQLState"] = _error;

//FIXME: ERR_FAIL_ just print
// FIXME: ERR_FAIL_just print
// ERR_PRINT(sqlError) ?


#ifdef TOOLS_ENABLED
print_line("# EXCEPTION Caught ˇ");
print_line("# ERR: SQLException in: "+String(file)+" in function: "+String(func)+"() on line "+String(line));
Expand Down Expand Up @@ -1092,19 +1097,22 @@ void MySQL::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_connection_metadata"),&MySQL::get_connection_metadata);
ClassDB::bind_method(D_METHOD("get_last_error"),&MySQL::get_last_error);


/* PROPERTIES */
ClassDB::bind_method(D_METHOD("get_property", "property"),&MySQL::get_property);
ClassDB::bind_method(D_METHOD("set_property", "property", "value"),&MySQL::set_property);
ClassDB::bind_method(D_METHOD("set_properties_array", "properties"),&MySQL::set_properties_array);
ClassDB::bind_method(D_METHOD("get_properties_array", "properties"),&MySQL::get_properties_array);


/* DATABASE */
ClassDB::bind_method(D_METHOD("query", "Sql Statement", "DataFormat", "Return data as String", "Metadata"),&MySQL::query, DEFVAL(DICTIONARY), DEFVAL(false), DEFVAL(PoolIntArray()) );
ClassDB::bind_method(D_METHOD("query_prepared", "sql_statement", "Values", "DataFormat", "return_string", "meta"), &MySQL::query_prepared, DEFVAL(Array()), DEFVAL(MySQL::DataFormat::DICTIONARY), DEFVAL(false), DEFVAL(PoolIntArray()));
ClassDB::bind_method(D_METHOD("execute", "sql_statement"),&MySQL::execute);
ClassDB::bind_method(D_METHOD("execute_prepared", "sql_statement", "Values"),&MySQL::execute_prepared);
ClassDB::bind_method(D_METHOD("update", "sql_statement"),&MySQL::update);
ClassDB::bind_method(D_METHOD("update_prepared", "sql_statement", "Values"),&MySQL::update_prepared);
ClassDB::bind_method(D_METHOD("query", "Sql Statement", "DataFormat", "Return data as String", "Metadata"),&MySQL::query, DEFVAL(DICTIONARY), DEFVAL(false), DEFVAL(PoolIntArray()) );
ClassDB::bind_method(D_METHOD("query_prepared", "sql_statement", "Values", "DataFormat", "return_string", "meta"), &MySQL::query_prepared, DEFVAL(Array()), DEFVAL(MySQL::DataFormat::DICTIONARY), DEFVAL(false), DEFVAL(PoolIntArray()));


/* CONNECTOR */
ClassDB::bind_method(D_METHOD("set_database", "database"),&MySQL::set_database);
Expand All @@ -1115,11 +1123,13 @@ void MySQL::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_catalog"),&MySQL::get_catalog);
ClassDB::bind_method(D_METHOD("get_client_info"),&MySQL::get_client_info);


/* CONN OPTIONS */
ClassDB::bind_method(D_METHOD("get_driver_info"),&MySQL::get_driver_info);
ClassDB::bind_method(D_METHOD("set_client_option", "option", "value"),&MySQL::set_client_option);
ClassDB::bind_method(D_METHOD("get_client_option", "option"),&MySQL::get_client_option);


/* TRANSACTION */
ClassDB::bind_method(D_METHOD("set_autocommit", "bool"),&MySQL::set_autocommit);
ClassDB::bind_method(D_METHOD("get_autocommit"),&MySQL::get_autocommit);
Expand All @@ -1132,6 +1142,7 @@ void MySQL::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_savepoints"),&MySQL::get_savepoints);


/* ENUMS */
BIND_ENUM_CONSTANT(TRANSACTION_ERROR);
BIND_ENUM_CONSTANT(TRANSACTION_NONE);
BIND_ENUM_CONSTANT(TRANSACTION_READ_COMMITTED);
Expand All @@ -1153,6 +1164,7 @@ void MySQL::_bind_methods() {
BIND_ENUM_CONSTANT(ARRAY);
BIND_ENUM_CONSTANT(DICTIONARY);


}


Expand Down
9 changes: 4 additions & 5 deletions mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class MySQL : public Reference{
};



private:

enum OP {
Expand Down Expand Up @@ -128,14 +127,14 @@ class MySQL : public Reference{
int get_prop_type( String p_prop );
int get_time_format( String time );
void _fit_statement( std::shared_ptr<sql::PreparedStatement> prep_stmt, std::stringstream *blob, Variant arg, int index );
PoolStringArray prop_string = String("hostName, userName, password, schema, pipe, pluginDir, postInit, preInit, readDefaultFile, readDefaultGroup, rsaKey, socket, sslCA, sslCAPath, sslCert, sslCipher, sslCRL, sslCRLPath, sslKey, characterSetResults, charsetDir, defaultAuth, defaultPreparedStatementResultType, defaultStatementResultType, OPT_TLS_VERSION, OPT_CHARSET_NAME").rsplit(", ");
PoolStringArray prop_bool = String("OPT_RECONNECT, CLIENT_COMPRESS, CLIENT_FOUND_ROWS, CLIENT_IGNORE_SIGPIPE, CLIENT_IGNORE_SPACE, CLIENT_INTERACTIVE, CLIENT_LOCAL_FILES, CLIENT_MULTI_STATEMENTS, CLIENT_NO_SCHEMA, OPT_REPORT_DATA_TRUNCATION, OPT_CAN_HANDLE_EXPIRED_PASSWORDS, OPT_ENABLE_CLEARTEXT_PLUGIN, OPT_GET_SERVER_PUBLIC_KEY, sslEnforce, sslVerify, useLegacyAuth").rsplit(", ");

PoolStringArray prop_int = String("port, OPT_CONNECT_TIMEOUT, OPT_LOCAL_INFILE, OPT_WRITE_TIMEOUT, OPT_READ_TIMEOUT").rsplit(", ");
PoolStringArray prop_map = String("OPT_CONNECT_ATTR_ADD").rsplit(", ");
PoolStringArray prop_list = String("OPT_CONNECT_ATTR_DELETE").rsplit(", ");
PoolStringArray prop_void = String("OPT_CONNECT_ATTR_RESET, OPT_NAMED_PIPE").rsplit(", ");


PoolStringArray prop_string = String("hostName, userName, password, schema, pipe, pluginDir, postInit, preInit, readDefaultFile, readDefaultGroup, rsaKey, socket, sslCA, sslCAPath, sslCert, sslCipher, sslCRL, sslCRLPath, sslKey, characterSetResults, charsetDir, defaultAuth, defaultPreparedStatementResultType, defaultStatementResultType, OPT_TLS_VERSION, OPT_CHARSET_NAME").rsplit(", ");
PoolStringArray prop_bool = String("OPT_RECONNECT, CLIENT_COMPRESS, CLIENT_FOUND_ROWS, CLIENT_IGNORE_SIGPIPE, CLIENT_IGNORE_SPACE, CLIENT_INTERACTIVE, CLIENT_LOCAL_FILES, CLIENT_MULTI_STATEMENTS, CLIENT_NO_SCHEMA, OPT_REPORT_DATA_TRUNCATION, OPT_CAN_HANDLE_EXPIRED_PASSWORDS, OPT_ENABLE_CLEARTEXT_PLUGIN, OPT_GET_SERVER_PUBLIC_KEY, sslEnforce, sslVerify, useLegacyAuth").rsplit(", ");


protected:

Expand Down

0 comments on commit 3efb496

Please sign in to comment.