Giter VIP home page Giter VIP logo

samkenx-hub-community / samkenxmysql-connector-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from samkenxstream/samkenxmysql-connector-python

0.0 1.0 0.0 19.87 MB

PhoenixDOM:rocket:: MySQL Connector/Python is implementing the MySQL Client/Server protocol completely in Python. No MySQL libraries are needed, and no compilation is necessary to run this Python DB API v2.0 compliant driver. Documentation & Download: http://samkenx.dev.mysql.com/doc/connector-python/en

Home Page: https:///samkenx.pypi.org/dev/mysql

License: Other

Shell 0.52% C++ 1.03% Python 93.57% C 4.60% Makefile 0.13% Dockerfile 0.13% Rich Text Format 0.02%

samkenxmysql-connector-python's Introduction

MySQL Connector/Python

MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the Python Database API Specification v2.0 (PEP 249). It also contains an implementation of the X DevAPI, an Application Programming Interface for working with the MySQL Document Store.

Installation

The recommended way to install Connector/Python is via pip.

Make sure you have a recent pip version installed on your system. If your system already has pip installed, you might need to update it. Or you can use the standalone pip installer.

shell> pip install mysql-connector-python

Please refer to the installation tutorial for installation alternatives.

Getting Started

Using the MySQL classic protocol:

import mysql.connector

# Connect to server
cnx = mysql.connector.connect(
    host="127.0.0.1",
    port=3306,
    user="mike",
    password="s3cre3t!")

# Get a cursor
cur = cnx.cursor()

# Execute a query
cur.execute("SELECT CURDATE()")

# Fetch one result
row = cur.fetchone()
print("Current date is: {0}".format(row[0]))

# Close connection
cnx.close()

Using the MySQL X DevAPI:

import mysqlx

# Connect to server
session = mysqlx.get_session(
   host="127.0.0.1",
   port=33060,
   user="mike",
   password="s3cr3t!")
schema = session.get_schema("test")

# Use the collection "my_collection"
collection = schema.get_collection("my_collection")

# Specify which document to find with Collection.find()
result = collection.find("name like :param") \
                   .bind("param", "S%") \
                   .limit(1) \
                   .execute()

# Print document
docs = result.fetch_all()
print(r"Name: {0}".format(docs[0]["name"]))

# Close session
session.close()

Please refer to the MySQL Connector/Python Developer Guide and the MySQL Connector/Python X DevAPI Reference for a complete usage guide.

Additional Resources

Contributing

There are a few ways to contribute to the Connector/Python code. Please refer to the contributing guidelines for additional information.

License

Please refer to the README.txt and LICENSE.txt files, available in this repository, for further details.

samkenxmysql-connector-python's People

Contributors

amitab avatar bkandasa avatar gipulla avatar isrgomez avatar johannes avatar kboortz avatar ltangvald avatar nawazn avatar nmariz avatar oscpache avatar peeyushgupta avatar prashanttekriwal avatar samkenxstream avatar sreedhars avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.