Skip to main content

All Questions

0 votes
1 answer
51 views

sqlite3.OperationalError: unable to open database file in virtual enviornment

I am trying to access a database named 'app.db' through sqlite3.connect() using a config with the URI of the file. I am also running this in a virtual enviornment and I am on windows. Here is where I ...
Lifeable's user avatar
0 votes
1 answer
40 views

How do I create a self joined table in SqlAlchemy for MySql

I am trying to create a self referencing table in MySql using SqlAlchemy. I get the error TypeError: Additional arguments should be named <dialectname>_<argument>, got 'ForeignKey' My ...
Kev12853's user avatar
0 votes
0 answers
77 views

Relationships are both of the same direction when declaring two-way foreign keys

For my ORM classes Trade, Order and Account (of stock markets) I want Order and Trade linked to each other by a foreign key, while setting the column in order to be nullable (an order may not have a ...
KCK's user avatar
  • 2,055
0 votes
1 answer
60 views

Python SQLAlchemy Update Operation Yielded Unexpected Result

In Python(FastAPI) SQlAlchemy(sqlite) Update Operation Yielded Unexpected Result. here the code # schemas.py class User(BaseModel): uid: int num: int # model.py class User(Base): ...
user27208323's user avatar
0 votes
2 answers
77 views

Best way to chunk data from SQLAlchemy based on date?

Imagine this table: class Entries(db.Model): __tablename__ = "entries" id = Column(Integer, primary_key=True, autoincrement=True) name = Column(Text) created_time = Column(...
doejoe's user avatar
  • 165
0 votes
0 answers
38 views

SQLAlchemy Updating ORM model after inserting it

async def upsert_record(record: Record) -> Record: async with async_session() as session: stmt = insert(Record).values( record.to_dict() ).on_conflict_do_update( ...
lisa.smith's user avatar
0 votes
1 answer
52 views

One to Many doesn't remove foreign key on delete in SQLAlchemy

Here's the setup: A User can have many images assigned (related_images), but can only have 1 profile image. class Photo(Model): __tablename__ = "photo" id = Column(Integer, ...
doejoe's user avatar
  • 165
0 votes
0 answers
47 views

Flask/SQLAlchemy combining paginate() and union() results together returns only integers?

I have separate queries that I want to union and then paginate together. Based on the SQLAlchemy docs for Flask, paginate() and Pagination: Call SQLAlchemy.paginate() on a select statement to get a ...
doejoe's user avatar
  • 165
0 votes
0 answers
52 views

SQLAlchemy 2.0 filtering multiple search terms across multiple many-to-many and one-to-many relationships?

What is an efficient query I can do to get all Item rows based on a list of include/exclude terms, with the text search also applying across the many-to-many and one-to-many relationships? I'm trying ...
doejoe's user avatar
  • 165
0 votes
1 answer
56 views

SQLAlchemy: to_sql create empty table after inspect

I have strange behavior here. After I init inspect(cn), to_sql writes an empty table to the database. def save_data_to_sql(df, table_name, cn): df.to_sql(con=cn, name='test_1', if_exists='...
Mike's user avatar
  • 328
0 votes
1 answer
126 views

Why show like this error in python in create engine for access the sql db?

import pandas as pd import sqlalchemy engine = sqlalchemy.create_engine('mysql+pymysql://root:NO@localhost:3306/application') df = pd.read_sql_table('customers',engine) df *RuntimeError:* '...
Thushan Sooriyaaarachchi's user avatar
0 votes
0 answers
51 views

Insert values from a list of dictionaries using SQLAlchemy Postgres in python

I have a table in RDS (aurora postgres) that looks like this: students: student_id (pk) student_name number_of_classes_taken one_violation multiple_violation 1234 joe_smith 1 False False 5678 ...
unlocknew's user avatar
0 votes
1 answer
32 views

Read real number as datetime object when creating an instance in Python class using SQLAlchemy

I have a datetime field in sqlite db which is stored as a UNIX timestamp. I want to read the same as a datetime object when creating the instances of the records. The code I am using is as such: from ...
mraabhijit's user avatar
0 votes
1 answer
843 views

Python-oracledb: DPY-6005: cannot connect to database (CONNECTION_ID=""). DPY-3008: unsupported in-band notification with error number 12572

I'm trying to connect to an Oracle database in Python using SQLAlchemy together with OracleDB. But I always get this error: sqlalchemy.exc.OperationalError: (oracledb.exceptions.OperationalError) DPY-...
mrlelis's user avatar
0 votes
1 answer
40 views

Way to update exitsting row from db sqlalchemy orm

Is there function updates data from db ex: user = User() user.name = 'Jonh' session.add(user) session.commit() session.foo(user) print(user.id) # now we have id of user ps: i am looking for foo() ...
RandomInternetUser's user avatar

15 30 50 per page
1
2 3 4 5
52