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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:17:34+00:00 2026-05-13T08:17:34+00:00

I am trying to understand this behavior. It’s definitely not what I expect. I

  • 0

I am trying to understand this behavior. It’s definitely not what I expect. I have two programs, one reader, and one writer. The reader opens a RDFlib graph store, then performs a query every 2 seconds

import rdflib
import random
from rdflib import store
import time

default_graph_uri = "urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52"

s = rdflib.plugin.get('MySQL', store.Store)('rdfstore')

config_string = "host=localhost,password=foo,user=foo,db=foo"
rt = s.open(config_string,create=False)
if rt != store.VALID_STORE:
    s.open(config_string,create=True)


while True:
    graph = rdflib.ConjunctiveGraph(s, identifier = rdflib.URIRef(default_graph_uri))
    rows = graph.query("SELECT ?id ?value { ?id <http://localhost#ha> ?value . }")
    for r in rows:
        print r[0], r[1]
    time.sleep(2)
    print " - - - - - - - - "

The second program is a writer that adds stuff to the triplestore

import rdflib
import random
from rdflib import store

default_graph_uri = "urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52"

s = rdflib.plugin.get('MySQL', store.Store)('rdfstore')

config_string = "host=localhost,password=foo,user=foo,db=foo"
rt = s.open(config_string,create=False)
if rt != store.VALID_STORE:
    s.open(config_string,create=True)

graph = rdflib.ConjunctiveGraph(s, identifier = rdflib.URIRef(default_graph_uri))

graph.add( ( 
            rdflib.URIRef("http://localhost/"+str(random.randint(0,100))), 
            rdflib.URIRef("http://localhost#ha"),
            rdflib.Literal(str(random.randint(0,100)))
            ) 
            )
graph.commit()

I would expect to see the number of results increment on the reader as I submit stuff using the writer, but this does not happen. The reader continues to return the same result as when it started. If however I stop the reader and restart it, the new results appear.

Does anybody know what am I doing wrong ?

  • 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-05-13T08:17:35+00:00Added an answer on May 13, 2026 at 8:17 am

    One easy fix is to put “graph.commit()” just after the line “graph = rdflib.ConjunctiveGraph(…)” in reader.
    I’m not sure what’s the cause and why commiting before read fixes this. I’m guessing that:

    • When opening MySQLdb connection, a transaction is started automatically
    • This transaction doesn’t see updates from other, later transactions.
    • “graph.commit()” bubbles down to some “connection.commit()” somewhere that discards this transaction and starts a new one.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to understand why this does not work. (Basic example with no validation
I'm trying to understand an estrange behavior in Python. I have the next python
I'm trying to understand this bit of code: in display.php: <html> ... <body> <table>
I don't know much about database optimization, but I'm trying to understand this case.
I was trying to understand something with pointers, so I wrote this code: #include
I've been learning C#, and I'm trying to understand lambdas. In this sample below,
After trying to understand why client code is not rendered in a page (injected
I am trying to understand why this design decision was made with the rename()
I'm trying to understand the exact behavior of storage class specifiers in C99, and
I'm trying to understand screen vs. print behavior. What's the reason the APSW docs

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.