sqlalchemy Questions

3

Solved

I am trying to connect to our remote sql server db via Jupyter Labs using the SQL magics. I can connect with a traditional connection string, but the SQL magics doesnt seem to work (which means I a...
Habiliment asked 7/5, 2019 at 22:39

1

I want to use multiprocessing module with sqlAlchemy in my custom class. Here is the code: from sqlalchemy import create_engine engine = create_engine(f'mysql+pymysql://a:b@localhost:3306/', serv...
Pennyweight asked 20/9, 2019 at 6:33

4

im very new to sqlite, im using macbook m1, im try to use jupyter notebook to do sql here is my code %load_ext sql import csv, sqlite3 con = sqlite3.connect("socioeconomic.db") cur = co...
Balboa asked 1/4, 2023 at 21:7

4

After installing pyodbc in a docker container I'm receiving the error: File "/root/.local/lib/python3.10/site-packages/sqlalchemy/connectors/pyodbc.py", line 43, in dbapi return __impor...
Dogmatist asked 14/4, 2023 at 20:21

3

I'm trying to connect the alembic library to the databases and sqlalchemy libraries. As a guide, I use this example link My projects file: db.py from databases import Database from sqlalchemy impor...
Yolk asked 15/7, 2020 at 15:8

3

Solved

I am attempting to execute a raw sql insert statement in Sqlalchemy, SQL Alchemy throws no errors when the constructed insert statement is executed but the lines do not appear in the database. As f...
Tooling asked 20/10, 2021 at 13:20

4

How to convert string to model type in FastAPI? If I have Student model and want to convert string student to type model. How to convert it? engine = create_engine(SQLALCHAMY_DATABASE_URL,pool_pre_...
Agenesis asked 30/5, 2023 at 10:33

2

Solved

Suppose I have the following (in Python 3 and SQLAlchemy): class Book(Base): id = Column(Integer, primary_key=True) chapters = relationship("Chapter", backref="book") class Chapter(Base): id =...
Patrimony asked 14/8, 2015 at 18:46

2

Solved

Suppose I have an engine pointing at MySQL database: engine = create_engine('mysql://arthurdent:answer42@localhost/dtdb', echo=True) I can populate dtdb with tables, FKs, etc by: metadata.creat...
Grigsby asked 15/5, 2009 at 21:19

5

Solved

I would like to use autoload to use an existings database. I know how to do it without declarative syntax (model/_init_.py): def init_model(engine): """Call me before using any of the tables or c...
Uttermost asked 24/12, 2010 at 13:2

6

I have a very simple SqlAlchemy model class User(Base): """ The SQLAlchemy declarative model class for a User object. """ __tablename__ = 'users' id = Column(Integer, primary_key=True) phone =...
Motley asked 3/7, 2012 at 14:49

3

I'm trying to use alembic with a MySQL engine to perform online migrations. I've found that when an operation in my onupgrade() method fails my database gets stuck in an inconsistent state and i ca...
Castanets asked 27/7, 2013 at 4:27

7

Solved

I'm trying to implement dynamic filtering using SQLAlchemy ORM. I was looking through StackOverflow and found very similar question:SQLALchemy dynamic filter_by It's useful for me, but not enough...
Ketron asked 23/12, 2016 at 16:52

12

Solved

I am trying to insert some data in a table I have created. I have a data frame that looks like this: I created a table: create table online.ds_attribution_probabilities ( attribution_type text,...
Dent asked 17/1, 2018 at 17:43

6

Solved

I'm trying to programmatically build a search query, and to do so, I'm joining a table. class User(db.Model): id = db.Column(db.Integer(), primary_key=True) class Tag(db.Model): id = db.Column(...
Riess asked 6/3, 2016 at 16:1

2

Solved

I wrote a Flask-SQLAlchemy model class that looks like this (from this reference): from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) db = SQLAlchemy(app) class...
Treharne asked 26/5, 2021 at 20:12

8

I have a table that already exists: USERS_TABLE = Table("users", META_DATA, Column("id", Integer, Sequence("user_id_seq"), primary_key=True), Column("first_name", String(255)), Column("last_nam...
Geopolitics asked 26/5, 2017 at 4:48

2

Solved

Assuming the following models, how exactly would one go about loading the shipment associated with the order via a subqueryload, filtered by the status of is_refunded? class Order(db.Model): id =...
Marbleize asked 11/3, 2015 at 18:24

3

I've been trying to figure out this for a while but a lot of answers I can find now are out-dated (posts from > 6 years ago), or less related. The question is really how to deal with database se...
Retiring asked 22/9, 2020 at 18:53

3

Solved

I'm trying to do some operations after an insert occurs on a particular table. user = ModelFactory.create_user(username, email, password) db.session.add(user) db.session.commit() So I have creat...
Florid asked 2/4, 2017 at 4:9

4

I am going through a flask/sqlalchemy tutorial https://pythonhosted.org/Flask-SQLAlchemy/quickstart.html#a-minimal-application and I configured my database url to be: postgres://username:password@...
Br asked 13/7, 2014 at 23:41

1

Solved

I am using alembic to manage my database changes. Other people may also add changes to this database. Everything is set up correctly and this is currebtly working fine. However, because we are many...
Plautus asked 27/7, 2023 at 11:12

2

Solved

I'm following this tutorial to adapt it to my needs, in this case, to perform a sql module where I need to record the data collected by a webhook from the gitlab issues. For the database module I'm...
Disenthral asked 22/3, 2022 at 10:38

8

Solved

I wrote a module which is to create an empty database file def create_database(): engine = create_engine("sqlite:///myexample.db", echo=True) metadata = MetaData(engine) metadata.create_all() ...
Baneberry asked 10/10, 2015 at 11:1

3

Solved

I have data for a particular entity partitioned across multiple identical tables, often separated chronologically or by numeric range. For instance, I may have a table called mytable for current da...
Innumerable asked 22/8, 2014 at 16:12

© 2022 - 2024 — McMap. All rights reserved.