Let’s say I have a simple table. In raw SQL it looks like this: CREATE TABLE events (id INT PRIMARY KEY) WITH (fillfactor=60); My question is how to specify fillfactor for a table using sqlalchemy declarative base? I’ve tried the following approach, but that didnt’t work: from sqlalchemy import Column, Integer, String from sqlalchemy.ext.declarative import ..
Category : postgresql
I want to host a django project on heroku. Locally, I developed it using MySQL database. And I have also pushed it to heroku but I get an Error message whenever I run heroku open command on command prompt. The error message is Can’t connect to local MySQL server through socket. Though I’m a newbie ..
Alright, new day, new query, happy life… SELECT dt.dt AS date FROM generate_series( ‘1986-02-01 00:00:00+01’::timestamp with time zone, ‘2021-01-14 00:00:00+01’::timestamp with time zone, ‘1 mon’::interval) dt(dt); so far so good. now let’s get this thing running in a nice script in psycopg2…. with connection.cursor() as cur: cur.execute( "SELECT dt.dt AS date FROM generate_series(" "’1986-02-01 00:00:00+01′::timestamp ..
I am trying to generate the following raw query using sqlalchemy core: SELECT library.name, (SELECT ARRAY (select book.title from books where book.library_id = 1 and book.is_free = false) as book_lists) from library where id = 1; So the query I generate in sqlalchemy is: query = sa.select( [ library.name, sa.func.array( sa.select( [books.title] ).where( sa.and_( books.c.library_id ..
I have code where I’d like to iterate over all rows in a table. I cannot store all the rows in memory so I have to use an iterator: cursor.execute("SELECT * FROM some_table;") for row in cursor: # cursor itersize is small do_something(row) Is it possible for another transaction to modify some_table while iterating? And ..
I need to create a web socket in Python to allow my Flutter app to communicate with Postgres DB. I know how to send commands from Python web socket to the db (as create table, query…) but I would like to receive commands from an extern source and then (automatically) forward these requests to the ..
I want to catch the PostGres query results that gets executed in the remote server (passwordless-ssh) via expect command that is used to supply the password for the given PostGres user. Actually, there are two versions of our application, the older version does not require Postgres password where as the new version requires it. So ..
Hi i wrote the insert APi inthe Api i am sending one json object as input parameter,even my function also working fine,when i am trying to executing the Api getting below error: cannot call json_populate_recordset on a scalar CONTEXT: SQL statement "insert into public."VOfficeApp_project_resources" (project_id,employee_id,assigned_date,assigned_by) SELECT v_project_id,employeeid,utcdatetime,assignedby FROM (select employeeid,assignedby from json_populate_recordset (NULL ::public.vofficeapp_project_resource_type,projectresource_json )) ..
I am using Python, Django and PostgreSQL for my application development. My Database has millions of records and I have to generate reports in real-time (runtime)using those data. While generating those reports the application gets timed out and not able to generate reports. if the data is around 50k it is generating an excel file ..
I have two modes one is IndexDetails and another is PriceIndex. In PriceIndex foreign key doesn’t map properly IndexDetails primary keys.parent_id should be between 1 to 4 but it doesn’t. class IndexDetails(Base): __tablename__ = ‘index_details’ __table_args__ = ({"schema": "demo"}) id = Column(Integer, primary_key=True,nullable= False, unique=True,autoincrement=True) ticker = Column(String(20)) name=Column(String(20)) region=Column(String(20)) # children = relationship("IndexPrice", back_populates="parent") ..
Recent Comments