MySQLi Articles

Found 3,404 articles

How to install Python MySQLdb module using pip?

Ankith Reddy
Ankith Reddy
Updated on 25-Mar-2026 3K+ Views

The MySQLdb module is a Python interface for connecting to MySQL databases. Since MySQLdb is not available for Python 3.x, we'll use PyMySQL or mysql-connector-python as modern alternatives. Why MySQLdb is Not Recommended MySQLdb only supports Python 2.x and is no longer maintained. For Python 3.x applications, use these alternatives ? PyMySQL − Pure Python MySQL client mysql-connector-python − Official MySQL driver Installing PyMySQL (Recommended) Open Command Prompt and install PyMySQL using pip ? pip install PyMySQL Example Usage import pymysql # Connection example (won't execute ...

Read More

How to store and retrieve date into Sqlite3 database using Python?

Rajendra Dharmkar
Rajendra Dharmkar
Updated on 24-Mar-2026 2K+ Views

You can easily store and retrieve dates in SQLite3 database using Python's sqlite3 module. When inserting dates, pass the datetime.date object directly and Python handles the conversion automatically by using the detect_types=sqlite3.PARSE_DECLTYPES parameter. Setting Up the Database Connection First, create a connection with date parsing enabled and set up a table ? import sqlite3 import datetime # Enable automatic date parsing conn = sqlite3.connect(":memory:", detect_types=sqlite3.PARSE_DECLTYPES) conn.execute('''CREATE TABLE TEST (ID TEXT PRIMARY KEY NOT NULL, DATE DATE)''') conn.commit() print("Table created successfully") Table created successfully Storing Dates in the Database Insert ...

Read More

How to convert MySQL DATETIME value to JSON format in JavaScript?

AmitDiwan
AmitDiwan
Updated on 15-Mar-2026 726 Views

To convert MySQL DATETIME values to JSON format in JavaScript, you can parse the datetime string into a Date object and then use JSON.stringify() to convert it to JSON. This is useful when working with MySQL data in web applications. Understanding MySQL DATETIME Format MySQL DATETIME format is typically YYYY-MM-DD HH:MM:SS. JavaScript's Date constructor can parse various date formats, making conversion straightforward. Method 1: Converting to JSON Object with Individual Components This approach extracts individual date components and creates a structured JSON object: // Simulate MySQL DATETIME string var mySQLDateTime = new Date("2019-09-06 ...

Read More

Does Ternary operation exist in MySQL just like C or C++?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 184 Views

Yes, ternary operation exists in MySQL using the CASE WHEN statement, which provides similar conditional logic to the ternary operator in C/C++. Let us first examine how the ternary operator works in C and then see its MySQL equivalent. Syntax C Ternary Operator: condition ? value_if_true : value_if_false MySQL Equivalent: CASE WHEN condition THEN value_if_true ELSE value_if_false END Example: C Ternary Operator Here is a complete C program demonstrating the ternary operator − #include int main() { int X = 5; ...

Read More

Extracting only date from datetime field in MySQL and assigning it to PHP variable?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 799 Views

In PHP, you can extract only the date from a MySQL datetime field using the DateTime class. This is useful when you need to display or process only the date portion without time information. Syntax DateTime::createFromFormat("Y-m-d H:i:s", yourDateTimeValue)->format("yourFormatSpecifier"); Example Here's how to extract only the date from a MySQL datetime value ? 13/02/2018 Different Date Formats You can format the extracted date in various ways by changing the format specifier ? Y-m-d format: 2018-02-13 F j, Y format: February ...

Read More

How to add auto-increment to column in MySQL database using PhpMyAdmin?

karthikeya Boyini
karthikeya Boyini
Updated on 15-Mar-2026 10K+ Views

You can add auto_increment to a column in MySQL database with the help of ALTER command. The syntax is as follows − ALTER TABLE yourTableName MODIFY yourColumnName INT NOT NULL AUTO_INCREMENT; Using PhpMyAdmin To open PhpMyAdmin on localhost, you need to type the following URL in your browser − localhost/phpmyadmin The PhpMyAdmin interface appears as follows − phpMyAdmin Database: AutoIncrementDemo Table: AutoIncrementDemo Field: UserId | Type: INT | Primary Key ...

Read More

How can I get enum possible values in a MySQL database using PHP?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 3K+ Views

You can get the enum possible values in a MySQL database using PHP by querying the INFORMATION_SCHEMA.COLUMNS table. This approach allows you to extract enum values programmatically without hardcoding them in your application. Database Setup First, let's create a sample table with an ENUM column ? CREATE TABLE EnumDemo ( Id int, Color ENUM('RED','GREEN','BLUE','BLACK','ORANGE') ); Method 1: Basic Query to Get Enum Values Use the INFORMATION_SCHEMA.COLUMNS table to retrieve the enum definition ? enum('RED','GREEN','BLUE','BLACK','ORANGE') Method 2: Extract Individual Enum Values Parse the enum string to get individual values as an array ?

Read More

Extract the Day / Month / Year from a Timestamp in PHP MySQL?

Samual Sam
Samual Sam
Updated on 15-Mar-2026 973 Views

To extract the Day/Month/Year from a timestamp in PHP, you can use the date_parse() function. This function parses a date string and returns an associative array with detailed date and time components. Syntax print_r(date_parse("anyTimeStampValue")); Example Let's extract day, month, and year from a timestamp using date_parse() ? Array ( [year] => 2019 [month] => 2 [day] => 4 [hour] => 12 [minute] => 56 ...

Read More

How to specify Decimal Precision and scale number in MySQL database using PHPMyAdmin?

Chandu yadav
Chandu yadav
Updated on 15-Mar-2026 2K+ Views

When working with DECIMAL data types in MySQL through PHPMyAdmin, you need to specify both precision and scale to properly store monetary values or other exact numeric data. This tutorial shows you how to configure decimal precision and scale using PHPMyAdmin interface. Understanding DECIMAL Precision and Scale The DECIMAL data type requires two parameters: DECIMAL(precision, scale) Where: Precision (X) − Total number of digits that can be stored Scale (Y) − Number of digits after the decimal point Example of DECIMAL Usage For DECIMAL(6, 4): Total digits: 6 Digits ...

Read More

How can we write PHP script to get the list of MySQL database?

Priya Pallavi
Priya Pallavi
Updated on 15-Mar-2026 2K+ Views

We can write PHP scripts to get the list of available MySQL databases using different approaches. Since the legacy MySQL extension is deprecated, we'll show modern methods using MySQLi and PDO. Using MySQLi Extension The MySQLi extension provides a simple way to list databases − Using PDO Extension PDO provides a more secure and flexible approach − Comparison Method Security Status Legacy MySQL Low Deprecated MySQLi High Active PDO High Active (Recommended) Conclusion Use ...

Read More
Showing 1–10 of 3,404 articles
« Prev 1 2 3 4 5 341 Next »
Advertisements