How to use the verticapy.utilities.check_types function in verticapy

To help you get started, we’ve selected a few verticapy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vertica / Vertica-ML-Python / verticapy / connections / connect.py View on Github external
def read_dsn(dsn: str):
	"""
---------------------------------------------------------------------------
Reads the DSN information from the ODBCINI environment variable.

Parameters
----------
dsn: str
	DSN name

Returns
-------
dict
	dictionary with all the credentials
	"""
	check_types([("dsn", dsn, [str], False)])
	f = open(os.environ['ODBCINI'], "r")
	odbc = f.read()
	f.close()
	if ("[{}]".format(dsn) not in odbc):
		raise ValueError("The DSN '{}' doesn't exist".format(dsn))
	odbc = odbc.split("[{}]\n".format(dsn))[1].split("\n\n")[0].split("\n")
	dsn = {}
	for elem in odbc:
		info = elem.replace(' ','').split('=')
		dsn[info[0].lower()] = info[1]
	return (dsn)
#---#
github vertica / Vertica-ML-Python / verticapy / connections / connect.py View on Github external
"""
---------------------------------------------------------------------------
Converts the ODBC dictionary obtained with the read_dsn method to the 
vertica_python format.

Parameters
----------
dsn: str
	DSN name

Returns
-------
dict
	dictionary with all the credentials
	"""
	check_types([("dsn", dsn, [str], False)])
	dsn = read_dsn(dsn)
	conn_info = {'host': dsn["servername"], 'port': 5433, 'user': dsn["uid"], 'password': dsn["pwd"], 'database': dsn["database"]}
	return (conn_info)
#---#
github vertica / Vertica-ML-Python / verticapy / connections / connect.py View on Github external
Method used to save the connection.
	auto           : uses vertica_python if vertica_python installed, 
		otherwise pyodbc, otherwise jaydebeapi.
	pyodbc         : ODBC.
	jaydebeapi     : JDBC.
	vertica_python : Vertica Python Native Client (recommended).
name: str, optional
	Name of the auto connection.

See Also
--------
change_auto_connection : Changes the current auto creation.
read_auto_connect      : Automatically creates a connection.
vertica_cursor         : Creates a Vertica Database cursor using the input method.
	"""
	check_types([
		("dsn", dsn, [dict], False),
		("method", method, ["auto", "pyodbc", "jaydebeapi", "vertica_python"], True)])
	if ("port" not in dsn):
		print("\u26A0 Warning: No port found in the 'dsn' dictionary. The default port is 5433.")
		dsn["port"] = 5433
	if ("user" not in dsn):
		print("\u26A0 Warning: No user found in the 'dsn' dictionary. The default user is 'dbadmin'.")
		dsn["user"] = "dbadmin"
	if (method == "auto"):
		try:
			import vertica_python
			method = "vertica_python"
		except:
			try:
				import pyodbc
				method = "pyodbc"