pycharmers.sdk.mysql module¶
-
class
pycharmers.sdk.mysql.PycharmersMySQL(host: Optional[str] = None, password: Optional[str] = None, user: Optional[str] = None, database: Optional[str] = None, verbose: bool = False)[source]¶ Bases:
pycharmers.sdk.base.PycharmersSQLWrapper class for MySQL.
- Parameters
host (Optional[str], optional) – host to connect. Defaults to
None.password (Optional[str], optional) – user to connect as. Defaults to
None.user (Optional[str], optional) – password to use. Defaults to
None.database (Optional[str], optional) – database to use. Defaults to
None.verbose (bool, optional) – Whether to print message or not Defaults to
False.
-
connect(func: Callable, host: Optional[str] = None, password: Optional[str] = None, user: Optional[str] = None, database: Optional[str] = None, **kwargs) → Optional[Union[pandas.core.frame.DataFrame, Tuple[tuple]]][source]¶ Use
MySQLdb.connectto create a connection to the database, and close it after excutingfunc.- Parameters
func (Callable) – The function you want to execute. Receive
cursoras the first argument.host (Optional[str], optional) – host to connect. Defaults to
None.password (Optional[str], optional) – user to connect as. Defaults to
None.user (Optional[str], optional) – password to use. Defaults to
None.database (Optional[str], optional) – database to ues. Defaults to
None.kwargs (dict) – See a table below.
- Returns
Return value of
func- Return type
Any
Keyword arguments for
MySQLdb.connectis below.Name
Type
Description
portintTCP/IP port to connect to
unix_socketstrlocation of unix_socket to use
convdictconversion dictionary, see MySQLdb.converters
connect_timeoutintnumber of seconds to wait before the connection attempt fails.
compressboolif set, compression is enabled
named_pipestrif set, a named pipe is used to connect (Windows only)
init_commandstrcommand which is run once the connection is created
read_default_filestrfile from which default client values are read
read_default_groupstrconfiguration group to use from the default file
cursorclasstypeclass object, used to create cursors (keyword only)
use_unicodeboolIf
True, text-like columns are returned as unicode objects using the connection``’s character set. Otherwise, text-like columns are returned as bytes. Unicode objects will always be encoded to the connection’s character set regardless of this setting. Default to ``True.charsetstrIf supplied, the connection character set will be changed to this character set.
auth_pluginstrIf supplied, the connection default authentication plugin will be changed to this value. Example values are
mysql_native_passwordorcaching_sha2_passwordsql_modestrIf supplied, the session SQL mode will be changed to this setting. For more details and legal values, see the MySQL documentation.
client_flagintflags to use or 0 (see MySQL docs or constants/CLIENTS.py)
ssl_modestrspecify the security settings for connection to the server; see the MySQL documentation for more details (mysql_option(), MYSQL_OPT_SSL_MODE). Only one of
'DISABLED','PREFERRED','REQUIRED','VERIFY_CA','VERIFY_IDENTITY'can be specified.ssldictdictionary or mapping contains SSL connection parameters; see the MySQL documentation for more details (mysql_ssl_set()). If this is set, and the client does not support SSL, NotSupportedError will be raised.
local_infileboolenables LOAD LOCAL INFILE; zero disables
autocommitboolIf False (default), autocommit is disabled. If
True, autocommit is enabled. If None, autocommit isn’t set and server default is used.binary_prefixboolIf set, the
'_binary'prefix will be used for raw byte query arguments (e.g. Binary). This is disabled by default.