Categories
Entrepreneurship General Topics and tips Tools & How-Tos

Should You Hire a Chinese Sourcing Agency?

China exports all kinds of products. After all, China is a mass manufacturing might. Many economies, big or small, are very much dependent on the products that are imported from China. If you are also considering importing goods from China, or have been importing for a while, would you consider hiring or partnering with a sourcing agency for your help? Or, would you like to go through the whole process all by yourself?

If you are willing to go through the whole purchasing process by yourself, then you may like to know how you can identify a real manufacturing company in China. And once you find an appropriate manufacturer or supplier, you would definitely want to know if they are even a legit company to deal with without legal or logistic issues.

A sourcing agent is your friend in need
A sourcing agent is your friend in need

Why Would You Even Consider Hiring a Sourcing Agency at First Place?

For many, finding the required product, choosing the right supplier, and getting through the supplier verification process is sometimes a tedious and a difficult job. You may want to get rid of this tiring effort.

Or, you may not have much time to spare before you would want your store be filled with the desired products.

Or, you may even don’t have much confidence in your skills or findings regarding your specific supplier.

Whether you are a novice importer, or have been importing from China for quite some time, you will find these questions at some point in your business. These issues are very much experienced by novice and seasoned importers alike. Naturally, you would want to ensure the safety of your investment.

In such cases, it sounds appropriate to transfer the burden of end to end sourcing and delivery on the hired shoulders of a sourcing agency. This arrangement will allow you to turn your focus away from dealing with the sellers all by yourself. In doing so, you can spend more time and energies on the selling part of your business and handling local business issues.

Many people are already looking for someone local for help

Most companies or small business owners rely on someone local in China to assist them in sourcing and closing a deal. Throughout my 16 or so years of stay in China, many of my friends have approached me for assisting them in dealing with their supplier. Many people contact me for the same purpose through social media or through references, just because I am here.

If you are dealing with a company for the first time, you would want to make sure they are operating legally. Off course, you would want to save your skin… and money, and do not want to be fooled by some company thousands of miles away.

The local agencies or sourcing companies in China can help you in doing these tasks for you. Off course they charge for their services, but that is an expense sometimes worth making.

How a Local Agency or a Product Sourcing Company Is Helpful for You?

As they say, there is no substitute for experience—and this benefit alone could be worth spending the money.

Think about the following reasons for hiring a product sourcing company.

Sourcing companies know their local market like the back of their hand.

Using their knowledge, they can potentially propose a much better plan for your business for you to use.

A sourcing agency typically have close ties with the local suppliers.

They may have worked with several suppliers and manufacturers in the past. Therefore, they can get a better deal most of the times because of their relationship with them.

They speak the local language.

The largest barrier in dealing with Chinese companies for most foreigners is the inability to speak the local language. When you hire a sourcing agency, the language will not become a barrier in dealing with the suppliers and performing negotiations. You do not want miscommunication in getting through your requirements. The sourcing agency can easily verify supplier’s documents that are typically in the local language.

They probably have heard every question multiple times that you have to ask.

Given their experience with other clients, they are almost always ready to satisfy your requirements and provide appropriate support.

They know the current dynamics of the market that you would probably not know if you are new.

For example, what regions are known for what kind of products, how suppliers can fool overseas buyers, and so on. This is an invaluable knowledge that can save your business from a setback.

They may have other clients who are looking for the same product as you.

If that is the case, then they can place a bigger order, and can get further discount from the supplier.

They know the best methods to negotiate with the companies and manufacturers in China.

They know the practices and customs of the local market. After finding the right manufacturer and knowing the right price, they use the right negotiation techniques to help you get the lower price without compromising on any of your requirements.

They save a lot of your time.

They have the right knowledge and specialized skills in procurement, and therefore can be more efficient in securing a deal.

Sourcing companies usually have a network of agents all over the country.

They can utilize their network and connections to serve your needs.

What Services Do They Usually Provide?

As a matter of fact, a product sourcing agency can provide many different services based on customers’ needs. You can an agency for the whole sourcing process, or only for the selected part of the job.

Consider these agencies as your one stop shop for your business in China.

They generally provide the following services.

Sourcing a product for your business

If you are looking to import products, but have no idea where to start. Or, you do not want to spend your time in researching and verifying the appropriate supplier. You can seek help of a sourcing agency in that case. The sourcing agency would provide you the end to end services, from finding the appropriate supplier, to shipping your products to your destination.

Helping in selecting the appropriate supplier for your products

You can hire a sourcing agency only to find an appropriate supplier for your business. You may want to take it over from there and further deal with the company by yourself.

Auditing factory, vetting and verification of supplier

You may have already found an appropriate supplier for your business, but you are not sure if they work legally in China and can really provide proper services. In such a case, you can hire the services of an agency to perform factory audits and verify the supplier’s credentials.

Evaluating product samples before issuing purchase order

You have already selected a supplier and are satisfied with them. Whether you want to avoid hefty overseas shipping charges on samples for some reason, or having time constraints, you can hire the agency to evaluate the samples for you and provide you a report.

Following up on orders

After you have placed the order, the agency can help you keeping an eye on the schedule. They can keep following up on orders as and when you require them.

Testing and inspecting your products before shipping

You can hire a sourcing agency to test and inspect the produced goods to make sure they are according to your requirements. They usually perform product inspection according to industry standards.

Handling shipping and logistics

The product sourcing agencies usually have relationships with several different freight forwarders. They coordinate with your supplier and freight forwarder, and utilize their contacts to send your shipment using the best way.

Providing other value adding services

Many sourcing agencies provide additional services; such as, private labeling, customizing the product or its label or its packaging, and so on. They also provide drop shipping and fulfillment services directly from Mainland China.

What Would They Usually Charge You for Their Service?

The sourcing agencies have different payment and compensation methods to charge for their services:

Price-based flat rate for buyer

This service fee is typically the percentage of the price of the goods purchased. The agency negotiates the price with the supplier on your behalf, and typically charge you between 1 and 10% of the total price. This method is completely open and transparent to you, and keep you involved in every aspect of the purchase process.

Price markup

The agencies with this method act as independent trading companies. They source the product for you, and provide you a price by adding their own commission on top of the product price. In this case, you would typically not know the actual price and source of the product. However, they make sure that all your requirements are met. They negotiate with the supplier and make all the arrangements according to your needs. That is, they take the complete responsibility of purchasing and exporting the product to your destination as per your requirements.

Purchase commission from supplier

This is the commission in percentage that the agency charges from the manufacturer or supplier. They usually team up with the supplier and act as their selling agent.

Commission from both buyer and supplier

The agencies with this method take commission from both parties. This method allows them to keep the commission low for both supplier and the buyer. For example, if they charge only the buyer or the supplier, they would charge 8% commission of the total amount. But if they charge both parties for their services, they would charge 4% each to earn that same 8% commission.

Charges for miscellaneous services

The agencies would charge a different services charges for other services that they offer. Such as, supplier verification, testing and inspection, and so on. These charges may or may not be based on the value of the product.

So Which Sourcing Agency Should You Partner with?

Are you more concerned about the source of the product? Or, quality and price of the product is more of your issue?

Consider the different services and methods mentioned above. Think about the services you need to hire, and the method that would suit you for the business. And based on that, find a sourcing agency that works with that mode.

A particular point of concern is that that a sourcing agency that charges commission from the supplier may have a biased interest towards the supplier. If an agency is charging a low fee for their services, there is no guarantee that they would not charge the supplier as well. When they do so, they may not work in the best interest of the buyers.

For example, when looking for suppliers, the agency successfully finds a supplier with the perfect match, who fulfills all the requirements. However, the supplier does not agree to the commission terms of the agency. In that case, the agency would let go that supplier in favor of the one who would pay them more commission.

This means, the sourcing agency that you hired to serve your interest, may compromise on some requirements when purchasing. They go ahead with the less qualified supplier. Why? Because that supplier pays them good commission.

That is why an independent agency that serve your interests and fulfill your requirements would always be a better choice. They charge relatively higher commission, but that commission would be much lower than what you would spend on traveling to China and doing the whole process by yourself. And traveling to China in the times of pandemic is not so convenient.

Conclusion

There are times when you need some “boots on the ground” to help you with your business with Chinese companies. You can hire a sourcing agency for that purpose, to help you with the complete purchasing process, or a part of the job. They provide plenty of options and services for you to choose from.

In other words, whatever you would like to do by yourself, if you were in China, they would do all that for you. At the times when you are not being able to travel to China, this indeed is a great help that you may wish you have.

Hits: 10

Categories
General Topics and tips Sotfware & Developers & DevOps Tools & How-Tos

How To Write MySQL CRUD Queries in Python

Are you wondering how to write MySQL CRUD Queries in Python?

You will see how to install MySQL Connector/Python, a module that allows us to connect MySQL database with Python and then how to write MySQL CRUD Queries in Python. Hence, after reading this post, you will know the answer to: “How To Write MySQL CRUD Queries in Python”.

In addition, if you want to read more about CRUD queries in MySQL follow the link.

Installing Python

MySQL CRUD Queries in Python
taken from: https://medium.com/@muddaprince456/mysql-python-e3627d541dd6

Before beginning with the article, it is important that you have Python installed. Additionally, it is important to note the version of Python you install (or if you already have Python installed). Python 3.9.7 is used– the latest release, for this tutorial However, you may use Python 3.7+ without any issues while following along with this tutorial.

Once you have downloaded it, head over to installing and tick the set path option. After that, you need to set up a couple more things to get started.

Create New MySQL User

Note that, this is an optional step which you may skip if you have already created a user. As I was creating a new user for the purposes of this post, I realized it might be helpful for some of you to see how it is done.

CREATE USER 'username' @ 'localhost' IDENTIFIED BY 'password';

All you have to do is swap in the actual username and password you want, and run the query on MySQL Command Line Client (CLI).

creating a new mysql user

Bonus step: You can grant permissions to this user account. Again, this is an optional step and you may skip ahead.

GRANT ALL PRIVILEGES ON 'database_name' TO 'username'@'localhost'

MySQL Connection With Python

A database driver module is used to connected programming languages with databases. Use a module called MySQL Connector/Python to connect MySQL with Python. Using this, you can write MySQL code and connect the databases in Python. Moreover, as a prerequisite to using its latest version (ver 8.0), you must have Python 3.8+ installed.

Connector/Python VersionMySQL Server VersionsPython VersionsConnector Status
8.08.0, 5.7, 5.6, 5.53.9, 3.8, 3.7, 3.6, (2.7 and 3.5 before 8.0.24)General Availability
2.2 (continues as 8.0)5.7, 5.6, 5.53.5, 3.4, 2.7Developer Milestone, No releases
2.15.7, 5.6, 5.53.5, 3.4, 2.7, 2.6General Availability
MySQL Connector/Python, Python, MySQL version compatibility list (from dev.mysql)

Alternatively, you may use PIP to install MySQL Connector/Python with the following command:

pip install mysql-connector-python
pip install mysql-connector-python, the module we will use for this post

PyMySQL

It must be known here, that while MySQL Connector/Python is the one primarily used, there are are database driver modules used for Python–MySQL connectivity, like PyMySQL, which requires Python 3.6+ and MySQL 5.6+ as prerequisites.

Establishing MySQL Connection With Python

Moving on, let’s see how to import this module and establish a connection with Python. The following block of code demonstrates this, syntactically. The first line imports this module with the use of an alias– mysql instead of writing the lengthy mysql.connector name.

import mysql.connector as mysql
mydb= mysql.connect(
  host="localhost",
  port = 3306,
  user="username",
  password="mysql_password",
)

Second key thing to note here is– 4 components or arguments pass in the .connect() method, which is used to establish the baseline connection.

These 4 arguments are:

  • host: specify the host; if it’s only local, then use ‘localhost’
  • port: the port MySQL listens on; usually 3306
  • user: specify a MySQL username
  • password: specify your MySQL password

Another important argument: database– write the name of a database that you want o connect to.

Now, I will demonstrate this connection with a real example that I used for the purposes of this blog. Although, word to the wise, don’t share your credentials with the world.

import mysql.connector as mysql
mydb = mysql.connect(
  host="localhost",
  port = 3306,
  user="sesame",
  password="opense",
)

Writing CRUD Queries In Python

This tutorial is made with the use of MySQL Connector/Python module– although you can use other database driver modules like PyMySQL.

After that, since the MySQL connection with Python is established already, let’s look at the actual process of writing CRUD queries with Python.

MYSQL Cursor Method In Python

MySQL .cursor() method executes the commands to communicate with the MySQL database

import mysql.connector as mysql

db= mysql.connect()
cursor = db.cursor()

Execute Method In Python

MySQL .execute() method is responsible for writing actual MySQL queries; everything written inside these double quotes is MySQL code.

mysql.execute("SELECT CURRENT_DATE")

Fetch Method In Python

.fetchone() fetches the next row of a query result set.

.fetchall() − It fetches all the rows in a result set.

fetch_db = cursor.fetchall()

fetch_db = cursor.fetchone()
print("Current Row: ", row[0])

Close Method In Python

This command closes the MySQL connection with Python.

mysql.close()

Summary:

Up until now, the basic code tokens/element–that are essential to most, if not all, MySQL queries in Python including connect, cursor, execute, fetch, and close– have been explained and shown with examples. You may read again if you want to clear something up, before moving to the next step.

summary of all basic key operations in mysql connection with python including connect, cursor, execute, fetch and close.

MySQL CRUD Queries in Python

MySQL CRUD queries refer to create, read, update and delete operations.

Create MySQL CRUD Queries in Python

The CREATE and INSERT keywords are a part of Create queries. Create queries are responsible for creating objects that store data.

Creating a Database

To create a database in MySQL, use the “CREATE DATABASE” keywords followed by the database name. This is all done inside the cursor’s method .execute() which is responsible for running these queries.

db_cursor = mydb.cursor()
db_cursor.execute(CREATE DATABASE demodb)
query to create a database

Creating a Table

Similarly, to create a table in MySQL in Python, the MySQL syntax is used– just like above. However, now replace DATABASE keyword with TABLE. The following is an example:

cursor= mydb.cursor()
cursor.execute(CREATE TABLE mytable ( 
               id int AUTO_INCREMENT PRIMARY KEY,
               first_name VARCHAR(50),
               last_name VARCHAR(50) NOT NULL
))
               
query to create a table in mysql

Insert Data In a Table

Populating a table in MySQL requires use of the INSERT keyword. As such, data can be added inside our table and fill it with information. To do so, follow this syntax:

cursor= mydb.cursor()
rows = "INSERT INTO table_name VALUES (%s/d %s/d)"
values = ('one'/1, 'second', 2)
cur.execute(rows, values)
query to insert data in mysql table mytable

Moreover, the %s lets you add string values in Python, while %d lets you add integer values in Python. After that, you can enter values in tuple form and then you can execute the cursor query.

cursor= mydb.cursor()
rows = "INSERT INTO mytable (first_name, last_name) VALUES (%s %s)"
values = ('one'/1, 'second', 2)
cur.execute(rows, values)

Do you want to insert multiple rows of data with one code block? Well, you can do that in Python. Therefore, instead of adding values as tuples, create a list of tuples; each tuple is a row in MySQL. Consequently, this not only helps you save time, but it also makes it easier to add numerous rows of data in a short amount of time.

The .executemany() method inserts these multiple tuples of data. In addition, note that .commit() is necessary to save these new rows of data.

alternative method of inserting data in table in mysql

Read MySQL CRUD Queries in Python

READ queries are written with the SELECT keyword. These queries are essential to visualize the changes made in MySQL or to retrieve data from tables.

Select Data From Table

Selecting data from tables helps us retrieve it for numerous reasons like checking attendance records, inventories, etc. SELECT has 6 clauses: FROM, WHERE, GROUP BY, HAVING, ORDER BY.

We can select tuples or columns of data that fulfill a certain condition or all of them. To retrieve all tuples/rows of data from a SQL query, we use .fetchall() method. Moreover, you can see that the output is in tuples.

cur.mydb.cursor()
cur.execute("SELECT * FROM mytable")
rows= cur.fetchall()
for row in rows:
    print(row)
select data from table with its clauses in mysql and python

If you want to retrieve only entry of data, use .fetchone().

cur.mydb.cursor()
cur.execute("SELECT * FROM mytable")
rows= cur.fetchone()
for row in rows:
    print(row)
select one row or tuple of data from table mysql

Update Queries In Python

Use UPDATE or ALTER keyword for Update queries..

Alter Table MySQL CRUD Queries in Python

What does it mean to alter a table? Well, let’s take an example. Imagine you created a database but your boss wants to add a new column to the database now.. But, it would be tiresome to create a new database with this column and hen populate it. Instead, you can simply use the ALTER keyword and add hat new column to your table. Similarly, you can make other type of changes like adding constraints.

cur.execute("ALTER TABLE mytable ADD address VARCHAR(255)")
mydb.commit()

It is important to note that the .commit() is necessary to save these changes to your database

alter table structure in python

Update Table In Python

If you’re in a business with real-life customers, you might come across situations where you need to update records– for eg, if an employee changes their living place, their address must be updated in the database as well to stay updated, no pun intend.

Update makes use of the clauses of SELECT keyword. Additionally, please note .commit(), which is, again, necessary to save changes.

cur.execute("UPDATE mytable SET last_name = 'dbcon' WHERE first_name = 'umar'

mydb.commit()

cur.execute("SELECT * FROM mytable")
rows = cur.fetchall()
for row in rows:
    print(row)
updates table with changes in data

Don’t specify the conditions and updates right away; this makes one vulnerable to SQL injection aback. Instead, to combat that, make use of %s and %d. Therefore, define their values in a tuple and execute with the query and values.

update data in table in a better way that prevents sql injection in python

Delete Queries In Python

Use DELETE or DROP keywords to write Delete queries. As such, this removes the records from table/database.

Delete Data From Table

Deleting data is useful and helps the database relevant, by removing unnecessary information. Hence, confirm deletion of a record with the .commit() in Python. Note that this removes all records– but the table still exists inside the memory.

cur.execute("DELETE FROM mytable WHERE last_name='dbcon'")
MySQL CRUD deletes rows or tuples of data in python

Drop Objects

Sometimes, you may want to drop a database or table if you made errors in defining it, or maybe the existing object type grew redundant. Similarly, you could want to make extra space in memory. As a result, use DROP keyword. After that, there is no existence of that object memory.

cur.execute("DROP DATABASE mydb")
python code for MySQL drop object

Conclusion To MySQL CRUD Queries in Python

In the end, it has been seen how to write MySQL CRUD queries in Python, step-by-step. This tutorial is for beginners, as well as, intermediate learners who may want to complement existing knowledge in either one of Python or MySQL, with the other.

A key takeaway is that about 10 lines of each MySQL query in Python repeat– where you define the database connection and create a cursor, and finally close the database at the end. As such, it’s easy to replicate/reuse this code for other MySQL queries. The only significant changes exist in the .execute() method.

Furthermore, it is safe to say that if you are familiar with MySQL’s syntax, it’s relatively easy to write the queries in Python– even if you’re unfamiliar with Python itself.

In conclusion, I hope you will find this post useful. Please share your thoughts in the comments below. Please do check our blog there a a lot of great posts there!. Lastly, let us know your thoughts about this post in the comments. Thanks for reading.

Hits: 20