This library helps you run MYSQL queries as fast as possible 🚄🔥!
Project description
cautious-pysql
CTpysql helps you to code mysql queries as fast as possible 🚄🔥
Usage
Installation
Use pip install ctpysql
to install the ctpysql and it's dependencies on your pc (or venv).
import module with:
from ctpysql import ctpysql
to use it in your project.
How it works?
You may import mysql.connector to work with ctpysql, just use:
from mysql.connector import (connection, Error)
and make a connection like this:
cnx = connection.MySQLConnection(user='root', password='password', host='127.0.0.1', database='db')
then make an object from ctpysql class using this connection:
obj = ctpysql(cnx)
after these steps you are able to use this library correctly, for example, insert query using dictionary values:
obj.insert('users', {'username': 'user1', 'password': 'password1'})
Supported queries
supported queries at this version (they will be more soon):
Mysql insert query (rowid return):
insert('table', {dictionary values})
Mysql table truncate query:
truncate('table')
Mysql select query (object return):
fetch('table', 'case [all or one]', 'type [dic or None]', **data)
Example:
fetch('users', 'one', None, id=3)
Mysql update query (affected rows count return):
update('table', 'condition column name', 'condition column value', **data)
Example:
update('users', 'username', usernameVar, password=123, email=a@a.com)
Mysql delete query (deleted rows count return):
delete('table', 'condition column name', 'condition value')
Mysql drop query ("Success" or error return):
drop('case', 'name')
Example:
drop('table', 'product')
Example2:
drop('view', '[mysql queries]')
Mysql order by query (fetched items return):
order('table', **data(column1="order like ASC", column2="order like DESC"))
Example:
order('products', name="ASC", id="DESC")
Mysql create table query ("Success" or error return):
create_table('table name', **data)
Example:
create_table('users', id="INT AUTO_INCREMENT PRIMARY KEY", name="VARCHAR(255)")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.