Mysql connector python anaconda

Connecting to MariaDB#

Anaconda Enterprise enables you to easily connect to MariaDB, a fork of MySQL relational database management system (RDBMS).

Before you can do so, however, you’ll need to install the mysql-connector-python conda package, which contains the Python driver for communicating with MySQL servers:

conda install -c anaconda mysql-connector-python 

NOTE: Any packages you install from the command line are available during the current session only. If you want them to persist, add them to the project’s anaconda-project.yml file. For more information, see Developing a project .

You can then use code such as this to connect to MySQL from within a notebook session:

import mysql.connector as mariadb import json # Read the credentials from secret credentials = None with open('/var/run/secrets/user_credentials/mariadb_credentials') as f: credentials = json.load(f) # Ensure your credentials were setup if credentials: # Connect to the DB connection = mariadb.connect( user=credentials.get('user'), password=credentials.get('password'), database='credentials.get('database'), host='credentials.get('host')' ) cursor = connection.cursor() # Execute the query cursor.execute("SELECT first_name, last_name FROM employees LIMIT 20") # Loop through the results for first_name, last_name in cursor: print(f'First name: first_name>, Last name: last_name>') # Close the connection connection.close() 

See Storing secrets for information about adding credentials to the platform, to make them available in your projects. Any secrets you add will be available across all sessions and deployments associated with your user account.

Источник

Connecting to MySQL#

Anaconda Enterprise enables you to easily connect to a MySQL relational database management system (RDBMS), to access the data stored in it.

Before you can do so, however, you’ll need to install the mysql-connector-python conda package, which contains the Python driver for communicating with MySQL servers:

conda install -c anaconda mysql-connector-python 

NOTE: Any packages you install from the command line are available during the current session only. If you want them to persist, add them to the project’s anaconda-project.yml file. For more information, see Developing a project .

You can then use code such as this to connect to MySQL from within a notebook session:

import mysql.connector as mysql import json # Get credentials from Kubernetes. The credentials were setup as a dictionary. credentials = None with open('/var/run/secrets/user_credentials/mysql_credentials') as f: credentials = json.load(f) # Ensure your credentials were setup if credentials: # Connect to the DB connection = mysql.connect( user=credentials.get('username'), password=credentials.get('password'), database='employees', host='support-mysql.dev.anaconda.com' ) cursor = connection.cursor() # Execute the query cursor.execute("SELECT first_name, last_name FROM employees LIMIT 20") # Loop through the results for first_name, last_name in cursor: print(f'First name: first_name>, Last name: last_name>') # Close the connection connection.close() 

See Storing secrets for information about adding credentials to the platform, to make them available in your projects. Any secrets you add will be available across all sessions and deployments associated with your user account.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

A conda-smithy repository for mysql-connector-python.

License

conda-forge/mysql-connector-python-feedstock

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Sign In Required

Please sign in to use Codespaces.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching GitHub Desktop

If nothing happens, download GitHub Desktop and try again.

Launching Xcode

If nothing happens, download Xcode and try again.

Launching Visual Studio Code

Your codespace will open once ready.

There was a problem preparing your codespace, please try again.

Latest commit

Git stats

Files

Failed to load latest commit information.

README.md

Package license: GPL-2.0-or-later WITH Universal-FOSS-exception-1.0

Summary: Python driver for communicating with MySQL servers

MySQL Connector/Python is a standardized database driver for Python platforms and development.

Installing mysql-connector-python from the conda-forge channel can be achieved by adding conda-forge to your channels with:

conda config --add channels conda-forge conda config --set channel_priority strict 

Once the conda-forge channel has been enabled, mysql-connector-python can be installed with conda :

conda install mysql-connector-python 
mamba install mysql-connector-python 

It is possible to list all of the versions of mysql-connector-python available on your platform with conda :

conda search mysql-connector-python --channel conda-forge 
mamba search mysql-connector-python --channel conda-forge 

Alternatively, mamba repoquery may provide more information:

# Search all versions available on your platform: mamba repoquery search mysql-connector-python --channel conda-forge # List packages depending on `mysql-connector-python`: mamba repoquery whoneeds mysql-connector-python --channel conda-forge # List dependencies of `mysql-connector-python`: mamba repoquery depends mysql-connector-python --channel conda-forge 

conda-forge is a community-led conda channel of installable packages. In order to provide high-quality builds, the process has been automated into the conda-forge GitHub organization. The conda-forge organization contains one repository for each of the installable packages. Such a repository is known as a feedstock.

A feedstock is made up of a conda recipe (the instructions on what and how to build the package) and the necessary configurations for automatic building using freely available continuous integration services. Thanks to the awesome service provided by Azure, GitHub, CircleCI, AppVeyor, Drone, and TravisCI it is possible to build and upload installable packages to the conda-forge Anaconda-Cloud channel for Linux, Windows and OSX respectively.

To manage the continuous integration and simplify feedstock maintenance conda-smithy has been developed. Using the conda-forge.yml within this repository, it is possible to re-render all of this feedstock’s supporting files (e.g. the CI configuration files) with conda smithy rerender .

For more information please check the conda-forge documentation.

feedstock — the conda recipe (raw material), supporting scripts and CI configuration.

conda-smithy — the tool which helps orchestrate the feedstock. Its primary use is in the construction of the CI .yml files and simplify the management of many feedstocks.

conda-forge — the place where the feedstock and smithy live and work to produce the finished article (built conda distributions)

If you would like to improve the mysql-connector-python recipe or build a new package version, please fork this repository and submit a PR. Upon submission, your changes will be run on the appropriate platforms to give the reviewer an opportunity to confirm that the changes result in a successful build. Once merged, the recipe will be re-built and uploaded automatically to the conda-forge channel, whereupon the built conda packages will be available for everybody to install and use from the conda-forge channel. Note that all branches in the conda-forge/mysql-connector-python-feedstock are immediately built and any created packages are uploaded, so PRs should be based on branches in forks and branches in the main repository should only be used to build distinct package versions.

In order to produce a uniquely identifiable distribution:

  • If the version of a package is not being increased, please add or increase the build/number .
  • If the version of a package is being increased, please remember to return the build/number back to 0.

Источник

Читайте также:  METANIT.COM
Оцените статью