Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8248887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:20:53+00:00 2026-06-07T23:20:53+00:00

I would like to fetch an array in MySQL. Can someone please tell me

  • 0

I would like to fetch an array in MySQL. Can someone please tell me how to use Python using MySQLdb to do so?

For example, this is what I would like to do in Python:

<?php

  require_once('Config.php'); 

  $q = mysql_query("SELECT * FROM users WHERE firstname = 'namehere'");
  $data = mysql_fetch_array($q);
  echo $data['lastname'];

?>

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:20:56+00:00Added an answer on June 7, 2026 at 11:20 pm
    1. Install MySQLdb (the drivers for MySQL for Python). Type pip install mysql-python
    2. Read up on the Python DB API, which is the standard way to access databases in Python.

    Then, try this:

    >>> import MySQLdb
    >>> connection = MySQLdb.connect(database='test')
    >>> cursor = connection.cursor()
    >>> cursor.execute('SELECT * FROM users WHERE firstname = %s',('somename',))
    >>> results = cursor.fetchall()
    >>> for i in results:
           print i
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I add data to an associative array? Using jQuery I would like
My Flash movie would like communicate with MySQL server to fetch and save data
Would like someone to take a look at my script and tell me where
I have this script below that i would like to tweak so it can
I would like to fetch the result set from a function for each row
I would like to create 3 different arrays which can change depending on which
How can I create an array of items from a generated list using a
I would like to be able to multiply all the prices for example from
I currently have this table. Names Two fields, ID and Names. Example data would
I am pulling data from a mysql DB. I would like to add the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.