Does Replit DB not work in production deployment?

Seems like it does not work - from replit import db returns None.

I created a web app in replit using flask and replit DB. Now I’ve been trying all day to deploy this web app without success.
I get this error from the logs tab:

Traceback (most recent call last): File "/home/runner/c535ac90-d901-4e81-824b-50af8dff6113/main.py", line 16, in <module> db[username] = {"username": username, "password": new_password} TypeError: 'NoneType' object does not support item assignment.

Thank you for considering my request.

1 Like

Thanks for reporting, I’ve passed this along to the engineering team :+1:

1 Like

+1 to this request. Without this feature, replits that run just fine on repl.co will fail when packaged as replit.app deployments.

Yes… This isn’t mentioned at all in the documentation, and it led to some embarrassment as I tested production deployment on my project

Also running into this same issue: “TypeError: ‘NoneType’ object does not support item assignment”

1 Like

Hey everyone, we’re working on this – it is supported but the mechanism is slightly different. We’re working on an update to the library that will use the new mechanism. Should be out soon.

3 Likes

We pushed a fix on version 3.3.0 of the Python package. It should work fine on deployments now.

Please let us know if you run into any issues.

1 Like

This still isn’t working for me. My deployments fail with the following error msg:

“error: The deployment failed to initialize due to a configuration or code error. Check the logs tab for more information. For additional support, please post on https://ask.replit.com/c/help/13 and a staff member will take a look.”

I double checked that I’m using the 3.3.0 python package. And when I comment out my replit db code, it deploys just fine.

Can you try deploying again? Also, do you see any errors in the Logs page?

3 Likes

still not working for me either
TypeError: ‘NoneType’ object does not support item assignment

when trying to print db it returns None

any update on this? i am not able to deploy my repl, fails at promotion stage. the program relies heavily on replit DB, wondering if this is not actually usable in a deployed repl?

does replit DB work with deployed node.js projects?

Is there an update to this question. I just tried to a deployment and I get the following error: AttributeError: 'NoneType' object has no attribute 'keys'. My Flask application works fine on the test server. Also, are we allowed to save temporary data in the file system on deployed applications?

Lm Moore,

Can we get the name of your Repl and I’ll get this over to the deployments team to take a look for you. Thanks!

This is laughable Replit - you’ve got core functionality issues that aren’t working and you’re trying to get us all to convert to Deployments for production in Jan 2024?!

You need to work this stuff out first before forcing users to something that doesn’t actually work the way it’s supposed to.

Same thing happened with me - I’m using Replit DB, tried to deploy, it deployed, but the db doesn’t work the same way it does in the development env… what’s the point of having a separate env for production if it doesn’t work the same way with the same code as the development env???

10/27/23 07:47:05 AM
db.set_raw(order_id, standard_order_details) # Use set_raw to set the raw JSON string

10/27/23 07:47:05 AM
AttributeError: 'NoneType' object has no attribute 'set_raw'

The DB didn’t initialize properly if it did that.

I’m sorry you’ve been having issues. You need to run poetry update replit on your Python project to get the latest version of the library, which has support for deployments. Version 3.3.0 and above of the replit library work with deployments.

1 Like

Ah. Well, unfortunately, I have some code that requires an older use of a specific package, which requires me to use an older version of replit. I guess I need to figure out a workaround for that.

I’m getting the same error @AdamElchert3 @breno-afb
From my deployment logs: AttributeError: ‘NoneType’ object has no attribute ‘keys’