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 8837697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:47:39+00:00 2026-06-14T09:47:39+00:00

I have a MySQL database with a table called sources , there I have

  • 0

I have a MySQL database with a table called sources, there I have two columns called srctype and url where srctype is a name (e.g: Hello) and url is an url (e.g: http://google.com)

In Python using SQLAlchemy, I could filter the srctype and get a list of the urls, for example;

src = "hello"    
links = session.query(sources).filter_by(srctype=src).all()

Easy, now I am migrating this data to a MongoDB, for this I am using pymongo.

I have a function where it saves the srctype and url to mongodb’s database

    def insertSources(self, srctype, link):
        """ Insert rss sources so we can parse them """
        new = {srctype: link}
        self.__sources.insert(new)

and a function that retrieves the srctype

 def getSources(self, type=None, single=True): # type == srctype
    if type:
        if single:
            return self.__sources.find_one()
        else:
            return iter(self.__sources.find({srctype:type}))
    else:
        if single:
            return self.__sources.find_one()
        else:
            return iter(self.__sources.find())

The problem here is, since there is no column called srctype and no column called url, how can I do the same as the SQLAlchemy/MySQL example?

In MySQL would be;

SELECT * FROM sources WHERE srctype="hello"

I wonder how will that be in the retrieve function I have (also in the insert function, since I am not sure if what I did there is correct for the job I want). In the insertSources function I simple add a dict to MongoDB, clearly I won’t be able to get the srctype in the getSources function, since srctype in MongoDB is no column.
Any help would be great.

  • 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-14T09:47:40+00:00Added an answer on June 14, 2026 at 9:47 am

    Your problem is that you are not setting the name correctly when saving the data. Instead of

    def insertSources(self, srctype, link):
        """ Insert rss sources so we can parse them """
        new = {srctype: link}
        self.__sources.insert(new)
    

    You should do

    def insertSources(self, srctype, link):
        """ Insert rss sources so we can parse them """
        new = {'srctype': srctype, 'link': link}
        self.__sources.insert(new)
    

    And similarly in getSources(). If srctype is passed, find() and find_one() should receive {'srctype': type}.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mysql database table called character with columns like name, strength, intelligence,
I have a MySQL database table called 'Videos' with only three columns (fields?): ID,
I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have a MySQL Database. In it's table is a field called 'itm_name' I'm
I have a mysql database with a table structure like below : Table Name
I have a table called profile in mysql database Table structure: user | hasimg
I have a table in my MySQL database called studentname . I made an
I have a MYSQL database table called 'wp_quotes' with a field that contains a
I have a MySQL database table called submission with a field called points with
I have a mySQL database table setup called site . Rather than qet 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.