Re: [sqlalchemy] sqlalchemy 2.0 and ABCMeta

2023-11-09 Thread Mike Bayer
hi - I'm not sure what the issue is but if you are tinkering with metaclasses, we first off have an alternate version of DeclarativeBase called DeclarativeBaseNoMeta that has no metaclass installed, and may be a better place to build off custom metaclass solutions as you wont need to be subcla

[sqlalchemy] sqlalchemy 2.0 and ABCMeta

2023-11-09 Thread 'Iwan Vosloo' via sqlalchemy
Hi there, We are migrating our code from SqlAlchemy 1.4 to 2.0 (2.0.23 to be specific). We have had the following, which allowed some classes inheriting from our Base to use an ABCMeta metaclass: --- class DeclarativeABCMeta(DeclarativeMeta, ABCMe

Re: [sqlalchemy] sqlalchemy returns None for sqlite tables which already have data

2023-05-22 Thread Mike Bayer
like someone mentioned there, showing the classes doesn't say much.I'd check that the table name is correct and definitely matches what's in the SQLite database that you are actually accessing, as well as that the primary key column in those tables is actually a primary key, or at least not

[sqlalchemy] sqlalchemy returns None for sqlite tables which already have data

2023-05-22 Thread m7mđ ĕğý
Hello mates, As my last msg had a so bad format i will keep the link of my original question on stackoverflow : https://stackoverflow.com/questions/76304295/sqlalchemy-returns-none-for-sqlite-tables-which-already-have-data i hope i get answers from you mates. Thanks -- SQLAlchemy - The

[sqlalchemy] sqlalchemy returns None for sqlite tables which already have data

2023-05-22 Thread m7mđ ĕğý
there is something wrong with those two sqlite tables: select method returns none but the table already have data. is that because product class is Primary key and a foreign key at the same time? - i use sqlalchemy - those two tables returns none every time i try to query them. - iha

[sqlalchemy] SQLAlchemy with MySQL on AWS Lambda is taking long time to truncate table

2022-12-13 Thread Chandra Prakash
On creating all tables using alembic for migrations and then truncate any empty table gets completed quickly, BUT once lambda function is triggered to insert some data in a table through SQLAlchemy ORM Session query (as given below) and then truncate the table takes very much time. Where is the

Re: [sqlalchemy] SQLAlchemy 2. psycopg3 type adapt

2022-09-11 Thread Mike Bayer
oh, I though you were asking how to use psycopg's API. If you want to use SQLAlchemy techniques, you would use TypeDecorator: https://docs.sqlalchemy.org/en/14/core/custom_types.html#augmenting-existing-types your type would look just like https://docs.sqlalchemy.org/en/14/core/custom_types.h

Re: [sqlalchemy] SQLAlchemy 2. psycopg3 type adapt

2022-09-11 Thread sector119
Thank You, Mike, I thought that I can adapt types with sqlalchemy, not with db adapter like psycopg, to make it not db adapter dependent solution. воскресенье, 11 сентября 2022 г. в 04:14:02 UTC+3, Mike Bayer: > maybe email on the psycopg2 list / github tracker > > On Sat, Sep 10, 2022, at 4:15

Re: [sqlalchemy] SQLAlchemy 2. psycopg3 type adapt

2022-09-10 Thread Mike Bayer
maybe email on the psycopg2 list / github tracker On Sat, Sep 10, 2022, at 4:15 PM, sector119 wrote: > Hello, > > I got exception when I try to insert numpy.int8 type data. > sqlalchemy.exc.ProgrammingError: (psycopg.ProgrammingError) cannot adapt type > 'int8' using placeholder '%s' (format: A

[sqlalchemy] SQLAlchemy 2. psycopg3 type adapt

2022-09-10 Thread sector119
Hello, I got exception when I try to insert numpy.int8 type data. sqlalchemy.exc.ProgrammingError: (psycopg.ProgrammingError) cannot adapt type 'int8' using placeholder '%s' (format: AUTO) I'm trying to adapt it with code below, but it looks like a bit comprehensive. Maybe you can suggest ano

[sqlalchemy] SqlAlchemy

2022-09-08 Thread hush Lee
I have a question about sqlalchmy is there someone help me fix it I wanner get the metadata of oracle self._db_meta.reflect(bind=self._engine, schema=self._schema) there is the log SAWarning: Did not recognize type 'LONG RAW' of column 'test_table' self._db_meta.reflect(bind=self._engine, schem

[sqlalchemy] SQLAlchemy exists() used with first() ?

2022-08-09 Thread Justvuur
Hi there, When creating another column property in a model that makes use of the exists(), I noticed that the exists does a "select *". *For example, the form exists below:* class Contact(ResourceMixin, db.Model): __tablename__ = 'contacts' form_contacts = db.relationship(FormContact, backre

Re: [sqlalchemy] SQLAlchemy 2 and Dialect’s has_schema()

2022-08-01 Thread Mike Bayer
On Sun, Jul 31, 2022, at 10:15 PM, jens.t...@gmail.com wrote: > Hello, > > I’m curious to get recommendations about the following use-case (based on > this SO Answer > ): > > *>>> import sqlalchemy*

[sqlalchemy] SQLAlchemy 2 and Dialect’s has_schema()

2022-07-31 Thread jens.t...@gmail.com
Hello, I’m curious to get recommendations about the following use-case (based on this SO Answer ): *>>> import sqlalchemy* *>>> configuration = {'sqlalchemy.url': 'postgresql+psycopg2://postgres:post

Re: [sqlalchemy] sqlalchemy serialization bug (TypeError: list indices must be integers or slices, not str)

2022-06-24 Thread Mike Bayer
1.4.39 is released On Fri, Jun 24, 2022, at 12:12 PM, Evgenii wrote: > Yes, it works > > пятница, 24 июня 2022 г. в 17:58:46 UTC+3, Evgenii: >> Sure, I can >> >> пятница, 24 июня 2022 г. в 17:06:39 UTC+3, Mike Bayer: >>> __ >>> if you can test this patch and confirm it reads your old pickle f

Re: [sqlalchemy] sqlalchemy serialization bug (TypeError: list indices must be integers or slices, not str)

2022-06-24 Thread Evgenii
Yes, it works пятница, 24 июня 2022 г. в 17:58:46 UTC+3, Evgenii: > Sure, I can > > пятница, 24 июня 2022 г. в 17:06:39 UTC+3, Mike Bayer: > >> if you can test this patch and confirm it reads your old pickle format, I >> can merge it and release 1.4.39 >> >> diff --git a/lib/sqlalchemy/ext/mut

Re: [sqlalchemy] sqlalchemy serialization bug (TypeError: list indices must be integers or slices, not str)

2022-06-24 Thread Evgenii
Sure, I can пятница, 24 июня 2022 г. в 17:06:39 UTC+3, Mike Bayer: > if you can test this patch and confirm it reads your old pickle format, I > can merge it and release 1.4.39 > > diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py > index 934ac37a05..cbec06a31f 100644 >

Re: [sqlalchemy] sqlalchemy serialization bug (TypeError: list indices must be integers or slices, not str)

2022-06-24 Thread Mike Bayer
if you can test this patch and confirm it reads your old pickle format, I can merge it and release 1.4.39 diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index 934ac37a05..cbec06a31f 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -502,

Re: [sqlalchemy] sqlalchemy serialization bug (TypeError: list indices must be integers or slices, not str)

2022-06-24 Thread Mike Bayer
hey there - yes this is unfortunately the case as we had to fix a bug in the mutable extension, issue 8133 doc'ed at https://docs.sqlalchemy.org/en/14/changelog/changelog_14.html#change-f8b03063d70397a8f275287ed2c8f2e6 . this seemed to be enough of an edge case that I didn't attempt to recon

[sqlalchemy] sqlalchemy serialization bug (TypeError: list indices must be integers or slices, not str)

2022-06-24 Thread Evgenii
Hello! We found bug in SA version `1.4.38` during deserialization. How to reproduce: Serialize any ORM object with pickle using environment with any SA compatible version `1.4.n` except `1.4.38` in , ex. `1.4.31`: ``` pickle.dumps(obj) ``` Deserialize result using environment with SA version ==

[sqlalchemy] SQLALCHEMY conncection to Sybase Adaptive Server Anywhere Version 7 via TCI/IP

2022-04-12 Thread Trainer Go
im a bit lost and need some help. im trying to set up a database connection with sqlalchemy to a Sybase Adaptive Server Anywhere Version 7 and i dont know how. I would be really happy if somebody could help me. Thanks in advace. Greetings Mae -- SQLAlchemy - The Python SQL Toolkit and Obje

Re: [sqlalchemy] SQLAlchemy + multiprocessing problems

2022-03-31 Thread Evgenii
Works! Thank you! четверг, 31 марта 2022 г. в 15:42:25 UTC+3, Mike Bayer: > when using multiprocessing, the connection pool in the new process must be > replaced with a new one. This is usually accomplished by calling > engine.dispose(). However, to maintain the pool in the parent process

Re: [sqlalchemy] SQLAlchemy + multiprocessing problems

2022-03-31 Thread Mike Bayer
when using multiprocessing, the connection pool in the new process must be replaced with a new one. This is usually accomplished by calling engine.dispose(). However, to maintain the pool in the parent process as well, replace the connection pool alone without disposing the old one: engine

[sqlalchemy] SQLAlchemy + multiprocessing problems

2022-03-31 Thread Evgenii
Hello! >From time to time, I need to update data in tables and multiprocessing can speed up this process. Last example: I’m trying to update data 7M rows in table SQLAlchemy 1.4.31, psycopg2 2.8.6, PostgreSQL def job_update_rd(data_list): updated = [] with Session() as session:

[sqlalchemy] SQLAlchemy exasol dialect maintainership transfer to Exasol AG

2022-01-27 Thread Peter Hoffmann
Hi all, after years of maintaining the sqlalchemy exasol dialect within Blue Yonder https://github.com/blue-yonder/sqlalchemy_exasol the Exasol AG has stepped up and offered to officially maintain the dialect in the future as part of their open source strategy. We are more than happy about thi

[sqlalchemy] SQLAlchemy with postgres: crash sqlalchemy connection with thread parallelism,

2021-12-15 Thread Ramin Farajpour Cami
Hi, I'm was testing the project by fastapi + sqlalchemy, i write golang code for sending thread parallelism to the my API endpoint, I found a problem, in the sqlalchemy many requests fail, this is my config : SQLALCHEMY_DATABASE_URL = config("DATABASE_URL") engine = create_engine(SQLALCHEMY

[sqlalchemy] SqlAlchemy with Postgres: How can I make a query that checks if a string is in a list inside a json column

2021-10-13 Thread chat...@gmail.com
Imagine a Postgres JSON column with values like below: "["user1", "user2"]" Is there any way to query a postgres JSON (not JSONB) column with SqlAlchemy,like above that checks if the value "user1" is contained in this column? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Map

Re: [sqlalchemy] SqlAlchemy 1.4 and Sequences

2021-09-01 Thread Mike Bayer
please upgrade to the most recent psycopg2 On Wed, Sep 1, 2021, at 6:12 AM, Francesca L wrote: > Thank you very much for your quick help. > > Yes, you are right, I was using the: "implicit_returning=False" flag on my > "create_engine()". > > I add the following, in case it can be useful to you

Re: [sqlalchemy] SqlAlchemy 1.4 and Sequences

2021-09-01 Thread Francesca L
Thank you very much for your quick help. Yes, you are right, I was using the: "implicit_returning=False" flag on my "create_engine()". I add the following, in case it can be useful to you: I removed the flag as suggested, and that's what I get now for the same code example (with sqlalchemy 1.4)

Re: [sqlalchemy] SqlAlchemy 1.4 and Sequences

2021-08-31 Thread Mike Bayer
issue https://github.com/sqlalchemy/sqlalchemy/issues/6963 is added to deal with possibly multiple failure modes in this case. On Tue, Aug 31, 2021, at 10:24 AM, Mike Bayer wrote: > Hi - > > Your test case is omitting a critical detail which we would assume is you are &g

Re: [sqlalchemy] SqlAlchemy 1.4 and Sequences

2021-08-31 Thread Mike Bayer
Hi - Your test case is omitting a critical detail which we would assume is you are using the "implicit_returning=False" flag on your create_engine().dont use this flag as it serves no useful purpose and that will fix your issue here, we will be deprecating and removing this flag. will try

[sqlalchemy] SqlAlchemy 1.4 and Sequences

2021-08-31 Thread Francesca L
Hi group, I am tring to migrate from version *1.3.24* to *1.4.23* of SqlAlchemy, using *PostgreSQL 10*. I found that the following code example works with 1.3, but triggers a traceback with 1.4. import sqlalchemy session = ... metadata = sqlalchemy.MetaData() s_items = sqlalchemy.Sequence('

Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-07-14 Thread Mike Bayer
As I mentioned on the github issue, aiopg's approach is one that has always alarmed me, which is that they have taken large tracts of SQLAlchemy's internals, copied them into their own source base, and simply altered them to fit their needs. I would never recommend this approach as it has n

Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-07-14 Thread Federico
Sqlalchemy 1.4 has asyncio support for postgresql using asyncpg. Not sure how feasible it is to replace that library for you. On Wed, 14 Jul 2021, 17:10 Marat Sharafutdinov, wrote: > The problem is the part of my code base depends on third party library > (aiopg) which should be compatible with

Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-07-14 Thread Marat Sharafutdinov
The problem is the part of my code base depends on third party library (aiopg) which should be compatible with SQLAlchemy 1.4 too but there some problems with it ( https://github.com/aio-libs/aiopg/issues/798#issuecomment-879815102 ) which make migration from 1.3 to 1.4 impossible for now =/ O

Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-06-10 Thread Mike Bayer
On Wed, Jun 9, 2021, at 7:21 PM, Marat Sharafutdinov wrote: > The problem is that currently only the entire codebase can be migrated from > 1.3 to 1.4, even though it can be extremely difficult or too long to do. > > I suggest the following way of pinning dependencies: > sqlalchemy==1.3 > sqlal

Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-06-10 Thread Federico Caselli
Hi, > The problem is that currently only the entire codebase can be migrated from 1.3 to 1.4, even though it can be extremely difficult or too long to do. I don't agree with this assessment. From my experience the main incompatibility is the url that has become immutable. Other than this most

Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-06-09 Thread Marat Sharafutdinov
The problem is that currently only the entire codebase can be migrated from 1.3 to 1.4, even though it can be extremely difficult or too long to do. I suggest the following way of pinning dependencies: sqlalchemy==1.3 sqlalchemy2==1.4 or sqlalchemy2==2.0 Then current codebase will continue to wo

Re: [sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-06-09 Thread Mike Bayer
hi there - having a separate project name on pypi doesn't solve any issue that isn't already solved by using version pinning - the "sqlalchemy" name on pypi is already at 1.4. the only way to install 1.3 is by requesting "pip install sqlalchemy < 1.4". As you've probably seen, SQLAlchemy 1.4

[sqlalchemy] SQLAlchemy 1.4 / 2.0 distribution

2021-06-09 Thread Marat Sharafutdinov
Currently I'm on SQLAlchemy 1.3 and there is a lot of work I have to do to migrate to 1.4 / 2.0. I think it's good idea to distribute 1.4 / 2.0 versions not only as "SQLAlchemy" project but as additional separate "SQLAlchemy2" project too with initial 1.4 version and then 2.0. This will give op

Re: [sqlalchemy] SQLAlchemy error when autogenerating documentation for database module using pdoc3

2021-05-05 Thread Yaakov Bressler
Will do, will follow up with results. On Wednesday, May 5, 2021 at 11:25:58 AM UTC-4 Mike Bayer wrote: > > > On Wed, May 5, 2021, at 11:18 AM, Yaakov Bressler wrote: > > *But when I try generating documentation for the entire project * > *(`MODULE='.'`)**, I get the following error:* > > > Import

Re: [sqlalchemy] SQLAlchemy error when autogenerating documentation for database module using pdoc3

2021-05-05 Thread Mike Bayer
On Wed, May 5, 2021, at 11:18 AM, Yaakov Bressler wrote: > *But when I try generating documentation for the entire project > **(`MODULE='.'`)**, I get the following error:* > > ImportError: Error importing 'PROJECT_NAME.database': > InvalidRequestError: Table 'FooBar' is already defined for thi

[sqlalchemy] SQLAlchemy error when autogenerating documentation for database module using pdoc3

2021-05-05 Thread Yaakov Bressler
Stack Overflow Link: https://stackoverflow.com/questions/67393499/sqlalchemy-error-when-autogenerating-documentation-for-database-module-using-pdo I'm creating documentation for a project using pydoc3 but am encountering an odd error from SQLAlchemy when running against my `database` module.

Re: [sqlalchemy] sqlalchemy get table with a string

2021-03-18 Thread FURKAN bilgin
Thank you for your response and I am immediately interested in your articles. 17 Mart 2021 Çarşamba tarihinde saat 20:46:11 UTC+3 itibarıyla Simon King şunları yazdı: > OK, I see. You're creating tables dynamically, and you want to be able > to insert data into those tables. > > I think it'll b

Re: [sqlalchemy] sqlalchemy get table with a string

2021-03-17 Thread Simon King
OK, I see. You're creating tables dynamically, and you want to be able to insert data into those tables. I think it'll be easier to use SQLAlchemy Core for this, rather than the ORM. You can use reflection to load table definitions from the database. https://docs.sqlalchemy.org/en/14/core/reflect

Re: [sqlalchemy] sqlalchemy get table with a string

2021-03-17 Thread FURKAN bilgin
I updated sqlalchemy and now I get an error when accessing the database. And their codes need to be coded: What I really wanted to do was add data to a table with json data in the / main / write path. but now I get an error when I send / main / new-app post request (I updated sqlalchemy and it h

Re: [sqlalchemy] sqlalchemy get table with a string

2021-03-17 Thread Simon King
I assumed you were defining classes corresponding to your database tables, as shown here: https://docs.sqlalchemy.org/en/14/orm/tutorial.html#declare-a-mapping If that's not how you're using SQLAlchemy, you'll have to show your code. Simon On Wed, Mar 17, 2021 at 2:07 PM FURKAN bilgin wrote: >

Re: [sqlalchemy] sqlalchemy get table with a string

2021-03-17 Thread FURKAN bilgin
I think we keep it in RAM in the first method, so it may be a problem if the program is restarted. and I guess I don't understand what you mean by Base class. 17 Mart 2021 Çarşamba tarihinde saat 14:27:31 UTC+3 itibarıyla Simon King şunları yazdı: > There are lots of ways of doing this. One opt

Re: [sqlalchemy] sqlalchemy get table with a string

2021-03-17 Thread Simon King
There are lots of ways of doing this. One option is to provide a dictionary when creating your declarative_base: classes = {} Base = declarative_base(class_registry=classes) Now you can look up classes by name in that classes dictionary: def get_table_by_name(name): return cl

[sqlalchemy] sqlalchemy get table with a string

2021-03-16 Thread FURKAN bilgin
*table_name = "table_name"* *#get table as table* *new = table(**tablo)db.session.add(table)db.session.commit()* -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable

Re: [sqlalchemy] SQLAlchemy database record created on import of module

2021-03-15 Thread Simon King
I suggest you set up an event listener for the "after_attach" event on your session: https://docs.sqlalchemy.org/en/13/orm/events.html#sqlalchemy.orm.events.SessionEvents.after_attach Then you can set a breakpoint in the listener (or raise an exception, or use the traceback module to print a stac

[sqlalchemy] SQLAlchemy database record created on import of module

2021-03-11 Thread Advanced Spectrum
I have a Base class like this: class FlagTable(Base): __tablename__ = "FLAG_TABLE" FLAG_TABLE_ID = Column(Integer, primary_key=True, autoincrement="auto") COLUMN_1 = Column(Boolean) COLUMN_2 = Column(Boolean) COLUMN_3 = Column(Boolean) I have a Python function in 'FlagTa

Re: [sqlalchemy] SQLAlchemy 1.3.23 turn off before_compile with **kwargs?

2021-03-01 Thread Mike Bayer
the before_compile event receives the Query object at the point it starts to turn it into a SQL construct. When this happens, it's in response to having said something like "query.all()". So there's no **kwarg that's specific to an operation like that. instead, when you want to send "message

[sqlalchemy] SQLAlchemy 1.3.23 turn off before_compile with **kwargs?

2021-03-01 Thread Chris Simpson
Hello I'd like to understand how to turn off a before_compile listener (e.g. soft delete, to include deleted items). For example, I've adapted the example from the docs: https://docs.sqlalchemy.org/en/13/orm/events.html?highlight=before_compile#sqlalchemy.orm.events.QueryEvents.before_compile

Re: [sqlalchemy] SQLAlchemy update on mysql updates less row than directly from IDE or command line

2021-02-14 Thread Vincent T
Hi Mike and thanks for taking the time to look into that. The query itself works fine. As mentioned it updates perfectly in mysql CLI or using a sql client like DBeaver. I followed your suggestion and tried using mysql.connector and the query works fine. In the meantime I also tried to use the *

Re: [sqlalchemy] SQLAlchemy update on mysql updates less row than directly from IDE or command line

2021-02-14 Thread Mike Bayer
looks like you are matching on timestamps. is there a timezone or date truncation issue occurring ? check the timestamps etc. and make sure they match up. Create small test scripts using SQLAlchemy with echo='debug' to see that the rows you expect are matching.your SQL query does not

[sqlalchemy] SQLAlchemy update on mysql updates less row than directly from IDE or command line

2021-02-14 Thread Vincent T
Mysql v8.0.23 on ubuntu 20.04 SQLAlchemy 1.3.22 Python 3.8.5 I have an SQL query as shown below that updates row in database. When run by command line or using DBeaver SQL editor, I get 583k lines updated. When using SQLAlchemy I get only 450k lines updated. i.e. some rows get updated but not al

[sqlalchemy] SQLAlchemy join/has query with example code

2021-02-06 Thread Chris Simpson
Hello, I'm trying to convert this working SQL query: (SQLAlchemy models are below) SELECT COUNT(*) FROM person JOIN subscription ON person.id = subscription.person_id JOIN plan ON subscription.sku_uuid = plan.uuid JOIN plan_requirements ON plan.id = plan_requirements.plan_id WHERE plan_requireme

Re: [sqlalchemy] SQLAlchemy (v.1.3.22) can not find Teradata engine inside Amazon Glue Job's script in Amazon environment

2021-02-04 Thread Simon King
;> On Mon, Feb 1, 2021 at 4:50 PM Anhelina Rudkovska >> wrote: >> > >> > >> > Everything works as expected on local machine. >> > >> > Code fails where SQLAlchemy db engine initializes. We use latest >> > (17.0.0.8) release of https

Re: [sqlalchemy] SQLAlchemy (v.1.3.22) can not find Teradata engine inside Amazon Glue Job's script in Amazon environment

2021-02-02 Thread Simon King
udkovska wrote: > > > Everything works as expected on local machine. > > Code fails where SQLAlchemy db engine initializes. We use latest (17.0.0.8) > release of https://pypi.org/project/teradatasqlalchemy/ library to provide DB > engine for SQLAlchemy. SQLAlchemy

[sqlalchemy] SQLAlchemy (v.1.3.22) can not find Teradata engine inside Amazon Glue Job's script in Amazon environment

2021-02-01 Thread Anhelina Rudkovska
Everything works as expected on local machine. Code fails where SQLAlchemy db engine initializes. We use latest (17.0.0.8) release of https://pypi.org/project/teradatasqlalchemy/ library to provide DB engine for SQLAlchemy. SQLAlchemy reports that it can not load plugin teradatasql. I

Re: [sqlalchemy] SQLAlchemy transaction ID

2021-01-29 Thread Mike Bayer
use to reproduce >>> this! >> >> So interesting fact, it looks like you are using Oracle for 2pc, that's what >> that tuple is, and we currently aren't including Oracle 2pc in our test >> support as cx_Oracle no longer includes the "twophase&qu

Re: [sqlalchemy] SQLAlchemy transaction ID

2021-01-29 Thread Thierry Florac
test support as cx_Oracle no longer includes the "twophase" flag which I > think we needed for some of our more elaborate tests. At the moment, > create_xid() emits a deprecation warning. I've been in contact with Oracle > devs and it looks like we should be supporting 2pc

Re: [sqlalchemy] SQLAlchemy transaction ID

2021-01-27 Thread 'Jonathan Vanasco' via sqlalchemy
he "twophase" flag which I > think we needed for some of our more elaborate tests. At the moment, > create_xid() emits a deprecation warning. I've been in contact with Oracle > devs and it looks like we should be supporting 2pc as I can get help from > them now

Re: [sqlalchemy] SQLAlchemy transaction ID

2021-01-27 Thread Mike Bayer
ate tests. At the moment, create_xid() emits a deprecation warning. I've been in contact with Oracle devs and it looks like we should be supporting 2pc as I can get help from them now for things that aren't working. I've opened https://github.com/sqlalchemy/sqlalchemy/issues

Re: [sqlalchemy] SQLAlchemy transaction ID

2021-01-27 Thread Thierry Florac
Hi, I'm actually using two databases connections: one is my "main" connection, opened on a ZODB (with RelStorage), and **sometimes** I have to open another connection on another database (and event more sometimes); the two transactions have to be synchronized: if one of them is aborted for any reas

Re: [sqlalchemy] SQLAlchemy transaction ID

2021-01-27 Thread Mike Bayer
On Wed, Jan 27, 2021, at 8:32 AM, Thierry Florac wrote: > > Hi, > I'm actually using SQLAlchemy with Pyramid and zope.sqlalchemy packages. > My main database connection is a ZODB connection and, when required, I create > an SQLAlchemy session which is joined to main transaction using this kind

[sqlalchemy] SQLAlchemy transaction ID

2021-01-27 Thread Thierry Florac
Hi, I'm actually using SQLAlchemy with Pyramid and zope.sqlalchemy packages. My main database connection is a ZODB connection and, when required, I create an SQLAlchemy session which is joined to main transaction using this kind of code: from sqlalchemy.orm import scoped_session, sessionmaker

Re: [sqlalchemy] SQLAlchemy array aggregate of objects

2020-11-05 Thread Mike Bayer
I think what's important here is to come up with the exact SQL string you'd like to create first, then if you can share that here we can show you how SQLAlchemy can render it from the expression language.As far as working with the PG functions someone else here might know or you can try stac

[sqlalchemy] SQLAlchemy array aggregate of objects

2020-11-05 Thread Wojtek K
Hi All, I'm trying to find the solution but with no success I have 2 tables related through assoc table table a id |name| -|| 1|example | assoc id |a_id | b_id | -|-|--| 1|1|1 | 2|1|2 | table b id |name | -|-| 1

[sqlalchemy] SQLAlchemy object aggregation

2020-11-05 Thread Wojtek K
Hi All, I'm trying to find the solution but with no success I have 2 tables related table a id |name| -|| 1|example | assoc id |a_id | b_id | -|-|--| 1|1|1 | 2|1|2 | table b id |name | -|-| 1|example1 | 2|ex

Re: [sqlalchemy] SQLAlchemy CORE: bindparam with postgresql on_conflict_do_update with a JSONB column

2020-09-15 Thread Massimiliano della Rovere
I removed all the tables from the DB and recreated them all (Settings among them) with alembic and everything worked. Thanks for your help, Mike! Il giorno mar 15 set 2020 alle ore 17:56 Mike Bayer < mike...@zzzcomputing.com> ha scritto: > here's one based on your samples of code, works fine on t

Re: [sqlalchemy] SQLAlchemy CORE: bindparam with postgresql on_conflict_do_update with a JSONB column

2020-09-15 Thread Mike Bayer
here's one based on your samples of code, works fine on this end, you can use this to see what you are doing differently. from sqlalchemy import bindparam from sqlalchemy import Column from sqlalchemy import create_engine from sqlalchemy import MetaData from sqlalchemy import String from sqlalche

Re: [sqlalchemy] SQLAlchemy CORE: bindparam with postgresql on_conflict_do_update with a JSONB column

2020-09-15 Thread Mike Bayer
this indicates a bindparam() object is being interpreted as a value somewhere but I can't reproduce that. can you provide an MCVE ? On Tue, Sep 15, 2020, at 11:33 AM, Massimiliano della Rovere wrote: > Yes, Mike, that solved the problem! I forgot to pass the column name. > > Now I get a dif

Re: [sqlalchemy] SQLAlchemy CORE: bindparam with postgresql on_conflict_do_update with a JSONB column

2020-09-15 Thread Massimiliano della Rovere
Yes, Mike, that solved the problem! I forgot to pass the column name. Now I get a different error: bindparam is not json-serializable. StatementError('(builtins.TypeError) Object of type BindParameter is not JSON serializable'), Is the JSONB column not supporting lazy/bindparam-compatible "prepar

Re: [sqlalchemy] SQLAlchemy CORE: bindparam with postgresql on_conflict_do_update with a JSONB column

2020-09-15 Thread Mike Bayer
the dictionary is with column names as keys: set_={"data": bindparam("timestamps")} hope this helps On Tue, Sep 15, 2020, at 10:55 AM, Massimiliano della Rovere wrote: > Greetings, > I am using SQLAlchemy==1.3.18. > > I have an SQLAlchemy "Settings" table with a "data" column defined as: >

[sqlalchemy] SQLAlchemy CORE: bindparam with postgresql on_conflict_do_update with a JSONB column

2020-09-15 Thread Massimiliano della Rovere
Greetings, I am using SQLAlchemy==1.3.18. I have an SQLAlchemy "Settings" table with a "data" column defined as: from sqlalchemy.dialects.postgresql import JSONB Settings = Table( "settings", self._metadata, # ... Column("data", JSONB, nullable=False)) and later in the code this

Re: [sqlalchemy] SQLAlchemy MYSQL query utf8 character problem

2020-09-03 Thread Simon King
On Thu, Sep 3, 2020 at 9:55 AM chat...@gmail.com wrote: > > Trying to query all items from a mysql (charset:utf8) table which has a field > that contains rows with chinese and other special characters I am taking the > above error > > items = session.query(Item).all() > > File > "/root/.local/s

[sqlalchemy] SQLAlchemy MYSQL query utf8 character problem

2020-09-03 Thread chat...@gmail.com
Trying to query all items from a mysql (charset:utf8) table which has a field that contains rows with chinese and other special characters I am taking the above error items = session.query(Item).all() File "/root/.local/share/virtualenvs/server-WesSANjA/lib/python3.8/site-packages/MySQLdb/cur

Re: [sqlalchemy] sqlalchemy messes up names with "_1" suffix

2020-07-10 Thread Mike Bayer
On Fri, Jul 10, 2020, at 8:50 AM, Xander Cage wrote: > hi, > > i have this litte flask-admin game running, now out of nowwhere sqlalchemy > has begun to add strange "_1" suffixes to the column names. i know sqlalchemy > does this to keep names unique, but in my case the queries are failing > a

[sqlalchemy] sqlalchemy messes up names with "_1" suffix

2020-07-10 Thread Xander Cage
hi, i have this litte flask-admin game running, now out of nowwhere sqlalchemy has begun to add strange "_1" suffixes to the column names. i know sqlalchemy does this to keep names unique, but in my case the queries are failing and my naming is unique. my models: ### DB models # Base model

[sqlalchemy] SQLAlchemy Filter Table using Model Methods

2020-07-08 Thread Padam Sethia
Hi , I want to filter my table using Model methods . So I have a method called get_gen_name() that gives me the actual item name from a combination of values in the tables & I want to search that . Any idea how do I achieve that ? I’m understand that there are hybrid properties / column expres

Re: [sqlalchemy] SQLAlchemy taking too much time to process the result

2020-07-06 Thread Mike Bayer
On Mon, Jul 6, 2020, at 2:14 PM, Saylee M. wrote: > Hello all, > Hope you are fine and safe in these times! > > I can be easily considered as a novice in SQLAlchemy. > I am trying to pull data from a MYSQL database from a table having around 20 > columns and more than 10 million rows. > The t

[sqlalchemy] SQLAlchemy taking too much time to process the result

2020-07-06 Thread Saylee M.
Hello all, Hope you are fine and safe in these times! I can be easily considered as a novice in SQLAlchemy. I am trying to pull data from a MYSQL database from a table having around 20 columns and more than 10 million rows. The table is partitioned and indexed. I am using a complex query, havin

Re: [sqlalchemy] sqlalchemy list connections inside connection pool

2020-05-06 Thread Mike Bayer
the connection pool reuses connections, so when you "close" a connection, often it is recycled so that it is returned to its pooled store rather than being fully closed. Some background on this is at https://docs.sqlalchemy.org/en/13/glossary.html#term-released On Wed, May 6, 2020, at 8:45 A

Re: [sqlalchemy] sqlalchemy list connections inside connection pool

2020-05-06 Thread Oğuzhan Kaya
what is mean that checkedout checkedin connection and why When connection is closed connection in pool number increases? 5 Mayıs 2020 Salı 19:50:22 UTC+3 tarihinde Mike Bayer yazdı: > > engine.pool has some metrics on it: > > >>> from sqlalchemy import create_engine > >>> e = create_engine("mysql

Re: [sqlalchemy] SQLAlchemy: UnicodeEncodeError: 'ascii' codec can't encode characters (db engine encoding ignored?)

2020-05-06 Thread Simon King
It might help to display the stack trace when the encoding fails, so we can see exactly where the error is coming from. Simon On Wed, May 6, 2020 at 9:01 AM Anno Nühm wrote: > > I am currently engaged in evaluating SQLAlchemy for a new project. When > trying to execute queries containing non-as

[sqlalchemy] SQLAlchemy: UnicodeEncodeError: 'ascii' codec can't encode characters (db engine encoding ignored?)

2020-05-06 Thread Anno Nühm
I am currently engaged in evaluating SQLAlchemy for a new project. When trying to execute queries containing non-ascii characters an exception is raised. The SQL statement used for carrying out the evaluation: SELECT owner, table_name FROM all_tables WHERE owner LIKE 'äöüßÄÖÜœ'; Executin

Re: [sqlalchemy] sqlalchemy list connections inside connection pool

2020-05-05 Thread Oğuzhan Kaya
Thanks mate you are a life saver. I think you mean this about event listeners. - what is dbapi_conn connection_rec and connection_proxy. I couldnt get it. def my_on_checkout(dbapi_conn, connectio

Re: [sqlalchemy] sqlalchemy list connections inside connection pool

2020-05-05 Thread Oğuzhan Kaya
thanks mate you are the best. but still one last thing missing which is the query(data) inside pool. 5 Mayıs 2020 Salı 19:50:22 UTC+3 tarihinde Mike Bayer yazdı: > > engine.pool has some metrics on it: > > >>> from sqlalchemy import create_engine > >>> e = create_engine("mysql://scott:tiger@local

Re: [sqlalchemy] sqlalchemy list connections inside connection pool

2020-05-05 Thread Mike Bayer
if you wanted to see the queue you could do this: >>> [rec.connection for rec in e.pool._pool.queue] [<_mysql.connection open to 'localhost' at 0x55ac3f6dfd20>, <_mysql.connection open to 'localhost' at 0x55ac3f6f52f0>] but for more general tracking of connection pool connections you would use

Re: [sqlalchemy] sqlalchemy list connections inside connection pool

2020-05-05 Thread Mike Bayer
engine.pool has some metrics on it: >>> from sqlalchemy import create_engine >>> e = create_engine("mysql://scott:tiger@localhost/test") >>> e.pool.status() 'Pool size: 5 Connections in pool: 0 Current Overflow: -5 Current Checked out connections: 0' >>> e.pool.checkedout() 0 >>> c1 = e.connect()

[sqlalchemy] sqlalchemy list connections inside connection pool

2020-05-05 Thread Oğuzhan Kaya
I made a connection with sqlalchemy to mssql and I used queue pool. I am trying to understand this connetion pool is worked or not. and also I want to see the connections and the queue inside connection pool how can I see? engine = sal.create_engine('IP',pool_size=1,max_overflow=0) result = engi

Re: [sqlalchemy] SQLAlchemy Access to Native Bulk Loaders

2020-04-22 Thread Benjamin Taub
Thank you for taking the time to lay that out, Jonathan. I am not sure if this will be a major issue for me yet or not and I would like to stay within SQLAlchemy to the greatest extent possible. Since I'm using the core, I think I'll try your second option. If I run into issues, I can rethink at th

Re: [sqlalchemy] SQLAlchemy Access to Native Bulk Loaders

2020-04-20 Thread Jonathan Vanasco
On Sunday, April 19, 2020 at 4:44:56 PM UTC-4, Ben wrote: > > > These seem to be embedded in the related SQL implementations but are > clearly not ANSI standard. I'm not sure if that makes it disqualifying for > a SQLAlchemy feature request, or if anyone else could even use it, but > functional

Re: [sqlalchemy] SQLAlchemy Access to Native Bulk Loaders

2020-04-19 Thread Richard Damon
On 4/19/20 4:44 PM, Benjamin Taub wrote: > Thanks for taking the time to respond, Richard. I may be thinking > about the command line option that you mentioned. However, I do see > that MySQL has a LOAD DATA statement > (https://dev.mysql.com/doc/refman/8.0/en/load-data.html) that, I > think, does

Re: [sqlalchemy] SQLAlchemy Access to Native Bulk Loaders

2020-04-19 Thread Benjamin Taub
Thanks for taking the time to respond, Richard. I may be thinking about the command line option that you mentioned. However, I do see that MySQL has a LOAD DATA statement (https://dev.mysql.com/doc/refman/8.0/en/load-data.html) that, I think, does what I'm thinking about. Similarly, Postgres has CO

Re: [sqlalchemy] SQLAlchemy Access to Native Bulk Loaders

2020-04-19 Thread Richard Damon
On 4/19/20 3:01 PM, Ben wrote: > Hi, James, thank you for the info. I'll give this a try. Still, it > does seem to require that the data be read into Python and then > written out to the DB, albeit quickly. What I'd prefer is a way to > issue a call to the DB to have it 'suck in' some csv file dire

Re: [sqlalchemy] SQLAlchemy Access to Native Bulk Loaders

2020-04-19 Thread Ben
Hi, James, thank you for the info. I'll give this a try. Still, it does seem to require that the data be read into Python and then written out to the DB, albeit quickly. What I'd prefer is a way to issue a call to the DB to have it 'suck in' some csv file directly, rather than having to read it

Re: [sqlalchemy] SQLAlchemy Access to Native Bulk Loaders

2020-04-19 Thread James Fennell
Hi Ben, Have you checked out bulk operations? https://docs.sqlalchemy.org/en/13/orm/persistence_techniques.html#bulk-operations Bulk operations provide a DB-agnostic API for doing large numbers of inserts and/or updates. The speed up you see, compared to session.add, depends on your database and

  1   2   3   4   5   6   7   8   9   10   >