Create Database in MariaDB using PyMySQL in Python Last Updated : 14 Oct, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report MariaDB is an open source Database Management System and its predecessor to MySQL. The pymysql client can be used to interact with MariaDB similar to that of MySQL using Python. In this article we will look into the process of creating a database using pymysql. To create a database use the below syntax: Syntax:CREATE DATABASE databaseName; Example : In this example we will be using the pymysql client to create a database named "GFG": Python # import the mysql client for python import pymysql # Create a connection object # IP address of the MySQL database server Host = "localhost" # User name of the database server User = "user" # Password for the database user Password = "" conn = pymysql.connect(host=Host, user=User, password=Password) # Create a cursor object cur = conn.cursor() # creating database cur.execute("CREATE DATABASE GFG") cur.execute("SHOW DATABASES") databaseList = cur.fetchall() for database in databaseList: print(database) conn.close() Output : The above program illustrates the creation of MariaDB database "GFG" in which host-name is 'localhost', the username is 'user' and password is 'your password'. Let’s suppose we want to create a table in the database, then we need to connect to a database. Below is a program to create a table in the GFG database which was created in the above program. Example : Python3 import pymysql conn = pymysql.connect('localhost','user','password','GFG') cur = conn.cursor() cur.execute("DROP TABLE IF EXISTS PRODUCT") query = """CREATE TABLE PRODUCT ( PRODUCT_ID CHAR(20) NOT NULL, price int(10), PRODUCT_TYPE VARCHAR(64) ) """ # To execute the SQL query cur.execute(query) # To commit the changes conn.commit() conn.close() Output : Comment More infoAdvertise with us Next Article Create Database in MariaDB using PyMySQL in Python P pratapworkmail Follow Improve Article Tags : Python Python-MariaDB Practice Tags : python Similar Reads Python MariaDB - Limit Clause using PyMySQL The Limit clause is used in SQL to control or limit the number of records in the result set returned from the query generated. By default, SQL gives out the required number of records starting from the top but it allows the use of the OFFSET keyword. OFFSET allows you to start from a custom row and 2 min read Create a database in MongoDB using Python MongoDB is a general-purpose, document-based, distributed database built for modern application developers and the cloud. It is a document database, which means it stores data in JSON-like documents. This is an efficient way to think about data and is more expressive and powerful than the traditiona 2 min read Create a database in MongoDB using Python MongoDB is a general-purpose, document-based, distributed database built for modern application developers and the cloud. It is a document database, which means it stores data in JSON-like documents. This is an efficient way to think about data and is more expressive and powerful than the traditiona 2 min read Create a database in MongoDB using Python MongoDB is a general-purpose, document-based, distributed database built for modern application developers and the cloud. It is a document database, which means it stores data in JSON-like documents. This is an efficient way to think about data and is more expressive and powerful than the traditiona 2 min read Create a database in MongoDB using Python MongoDB is a general-purpose, document-based, distributed database built for modern application developers and the cloud. It is a document database, which means it stores data in JSON-like documents. This is an efficient way to think about data and is more expressive and powerful than the traditiona 2 min read Like