[sqlalchemy] Re: sqlacodegen --noclaases depracated?

2023-11-09 Thread Jonathan Vanasco
sqlacodegen is a third party tool. Your best option for support is on their Github page: https://github.com/agronholm/sqlacodegen/discussions/categories/q-a On Monday, October 23, 2023 at 2:38:15 PM UTC-4 peter.dani...@gmail.com wrote: > SQLAlchemy and sqlacodegen noob here. I'd like to

[sqlalchemy] Re: session.close() is not wokring sqlalchemy i have tried diffrent diffrent way but it's not working i am trying sqlalchemy session in python but it's not working still getting session a

2023-07-07 Thread Jonathan Vanasco
That is working as intended. `close()` just resets the session and connection, returning it to a connection pool to be used again. https://docs.sqlalchemy.org/en/20/orm/session_basics.html#closing The Session.close()

Re: [sqlalchemy] Re: Dealing with readonly column

2023-04-18 Thread Jonathan Vanasco
FWIW, I often use the events to ensure an object or column is "read only". Sometimes I also will use two different attributes, where `Object.foo` is a getter for `Object._foo` in the database. The database will raise an error (hopefully) if I try to write to a 'protected column', and

[sqlalchemy] Re: trying to create a custome dialect did not find proper step guide

2023-04-12 Thread Jonathan Vanasco
you please guide me about how to > create a customs dialect because in sqlalchemy i find a topic on 3rd party > dialect but i dont fine and proper guide for it if you can please can you > provide me guide. > > > On Friday, April 7, 2023 at 11:12:14 PM UTC+5:30 Jonathan Vanasco wr

[sqlalchemy] Re: trying to create a custome dialect did not find proper step guide

2023-04-07 Thread Jonathan Vanasco
Most custom dialects are written by forking an existing dialect. Unfortunately, a dialect can not accomplish what you want to do. SqlAlchemy Dialects are used to generate SQL, which is then passed to the database via a DBAPI driver. For example, when someone uses PostgreSQL with SQLAlchemy,

Re: [sqlalchemy] Re: Working with func in dates, No response, no error message

2023-04-05 Thread Jonathan Vanasco
> The only difference between my code and yours is that I am not using sessions. The Flask-Sqlalchemy package handles all the session stuff automatically in the background. The code you write is not interacting with the session explicitly, but it is utilizing the session implicitly. IMHO,

[sqlalchemy] Re: TLS 1.2

2023-03-28 Thread Jonathan Vanasco
Many users with similar experiences ultimately traced the issue to an outdated database driver. I would try updating your driver. If that does not work, please share the driver + version, and your connection string / code. On Monday, March 27, 2023 at 2:39:21 PM UTC-4 pdb...@g.clemson.edu

Re: [sqlalchemy] Re: testing patterns with sqlalchemy 2.0

2022-09-02 Thread Jonathan Vanasco
ojects with under 20 tables, but some legacy applications with hundreds of tables. On Friday, September 2, 2022 at 2:47:05 AM UTC-4 Chris Withers wrote: > On 01/09/2022 20:00, Jonathan Vanasco wrote: > > > > > Create an empty schema from the models using create_all? > >

[sqlalchemy] Re: testing patterns with sqlalchemy 2.0

2022-09-01 Thread Jonathan Vanasco
> Create an empty schema from the models using create_all? This is what I usually do with smaller projects. On some large legacy projects, I use a database dump that is loaded into Postgres - as they often rely on a lot of records that need to be in the database and generating them via

[sqlalchemy] Re: Filling up a field in a database from a text file, flask

2022-08-22 Thread 'Jonathan Vanasco' via sqlalchemy
You should ask this in a Flask discussion group or stackoverflow. This is a sqlalchemy group and most users here have no experience with Flask. On Friday, August 19, 2022 at 4:13:50 PM UTC-4 nand...@gmail.com wrote: > I am trying to fill up a field in a table database with contents of a text

[sqlalchemy] Re: SQL Alchemy TypeDecorator

2022-08-09 Thread 'Jonathan Vanasco' via sqlalchemy
This is usually done in the ORM with functions, and possibly hybrids. See https://docs.sqlalchemy.org/en/14/orm/mapped_attributes.html On Tuesday, August 9, 2022 at 1:55:45 PM UTC-4 Justvuur wrote: > Hi there, > > Is there a way to pass/access model data for a row within the " >

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

2022-08-09 Thread 'Jonathan Vanasco' via sqlalchemy
I think you misunderstand `exists()` in SQLAlchemy and SQL. `exists()` is a convenience function to create a SQL `EXISTS` clause, which is an operator used for filtering subqueries. The 'from_exists' is just a subquery. It is supposed to be used within a query which would then limit the

[sqlalchemy] Re: Shared ORM objects between threads

2022-07-05 Thread 'Jonathan Vanasco' via sqlalchemy
> I'm guessing we shouldn't be passing ORM objects to threads, but rather just passing IDs and then querying the full object in the thread function Correct. Database Connections and Sessions are not threadsafe, they are thread-local. See

Re: [sqlalchemy] simple query takes to long

2022-06-08 Thread 'Jonathan Vanasco' via sqlalchemy
When you select in the database ui tool, you are just displaying raw data. When you select within your code snippets above, Python is creating pandas' DataFrame objects for the results. These two concepts are not comparable at all. Converting the SQL data to Python data structures in Pandas

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

2022-04-14 Thread 'Jonathan Vanasco' via sqlalchemy
>> [Microsoft][ODBC Driver Manager] Der Datenquellenname wurde nicht gefunden, >> und es wurde kein Standardtreiber angegeben (0) (SQLDriverConnect)') >> (Background on this error at: http://sqlalche.me/e/14/rvf5) >> >> i have installed the driver on my computer

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

2022-04-13 Thread 'Jonathan Vanasco' via sqlalchemy
The Sybase dialect was deprecated from first-party support by SQLAlchemy and is currently unsupported. Gord Thompson, who is a frequent contributor to the core SQLAlchemy project, and has generously taken over responsibility for the original dialect as a third-party dialect::

[sqlalchemy] Re: create database name lowcase ?

2022-03-31 Thread 'Jonathan Vanasco' via sqlalchemy
I'm not aware of any recent changes in the libraries that would cause that behavior. It may be how you are using the libraries or raw sql. PostgreSQL will convert database names to lowercase UNLESS the database name is in quotes. These will all create `abc`: CREATE DATABASE abc;

Re: [sqlalchemy] Re: many-to-many orm warnings

2022-03-15 Thread 'Jonathan Vanasco' via sqlalchemy
I'm sorry you're getting bit by this messaging - but also glad that I'm not the only one. This got me a while ago too. SqlAlchemy just uses a bare field name when emitting the warning and accepting the `overlaps` arguments. In more complex models with 3+ tables that have standardize

[sqlalchemy] Re: [Proposal] Some simple high-level feature to set connection timeouts

2022-01-10 Thread Jonathan Vanasco
SQLAlchemy supports connection timeouts to establish a connection already. SQLAlchemy does not, and can not, support query timeouts. This is possible with some python database drivers, but very rare. In every Python database program/library query timeouts are typically handled on the database

Re: [sqlalchemy] [Question] Why not passing Connection URL query parameters to the dialect?

2022-01-07 Thread Jonathan Vanasco
> Ok. So if I understand you correctly, you want to keep query parameters solely for DBAPI drivers connection parameters and would hence not accept a PR that would implement something that changes that. Just adding: the standard across programming languages and database products/projects is to

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

2021-12-20 Thread Jonathan Vanasco
Please submit a "Short, Self Contained, Correct (Compilable), Example" along with any potential bug reports. http://sscce.org/ On Wednesday, December 15, 2021 at 11:29:30 AM UTC-5 Ramin Farajpour Cami wrote: > Hi, > > I'm was testing the project by fastapi + sqlalchemy, i write golang code >

Re: [sqlalchemy] Dialect-specific dispatch in user code

2021-10-25 Thread Jonathan Vanasco
Adding that on top of Mike's approach, you may also want to create some custom functions via the @compiles decorator: https://docs.sqlalchemy.org/en/14/core/compiler.html This would allow you to further customize the SQL emitted against Postgres vs SQLite as needed.For example, I have some

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

2021-10-18 Thread Jonathan Vanasco
I'm not sure, but AFAIK, this type of search isn't *easily* doable in PostgreSQL. The json and jsonb operators and functions are really targeting "object literals" style data, not lists. https://www.postgresql.org/docs/current/functions-json.html In the past, I think one could search against

[sqlalchemy] Re: Calculate rank of single row using subquery

2021-09-14 Thread 'Jonathan Vanasco' via sqlalchemy
> Is this the most efficient way to do this, or am I over-complicating it? That roughly looks like code that I've implemented in the past. If it works and you don't have issues, I wouldn't worry about efficiency. Stuff like this will often vary based on the underlying table data - the

[sqlalchemy] Re: AsyncEngine always returns UTC time for datetime column

2021-09-14 Thread 'Jonathan Vanasco' via sqlalchemy
Can you share the database drivers / dialects you use? The discrepancy could be there. On Tuesday, September 14, 2021 at 7:03:27 AM UTC-4 ivan.ran...@themeanalytics.com wrote: > Hi all, > > I am trying to figure it out why AsyncEngine always returns UTC time for > datetime column, any help is

Re: [sqlalchemy] Change in before_flush (maybe from 1.3 to 1.4?)

2021-09-09 Thread 'Jonathan Vanasco' via sqlalchemy
What version of 1.4 are you using? It is before 1.4.7? If so, please update to the latest (1.4.23 is current) There was a regression in some early 1.4s that affected flush/commit/transaction in some situations. That was solved in 1.4.7. On Thursday, September 9, 2021 at 8:52:59 AM UTC-4 Mike

[sqlalchemy] Re: sqlite setting foreign_keys=off temporarily

2021-08-10 Thread 'Jonathan Vanasco' via sqlalchemy
The first two things I would look into: 1. Check the sqlite install/version that SqlAlchemy uses. It is often NOT the same as the basic operating system install invoked in your terminal. Sometimes that version does not have the functionality you need. 2. Check the transactional isolation

[sqlalchemy] Re: Oracle connection problem

2021-08-06 Thread 'Jonathan Vanasco' via sqlalchemy
You should ensure the connection string does not have any reserved/escape characters in it. People have had similar issues in the past. If that is the case, there are some recent threads in this group and on the github issues that show how to overcome the issue by building a connection string

[sqlalchemy] Re: Testing and deprecation of nested transactions

2021-07-30 Thread 'Jonathan Vanasco' via sqlalchemy
I typically do local developer testing with sqlite3, and the switch the database to postgresql for build/deploy/ci testing in the cloud. For complex tests, I typically use a fresh database "image". e.g. a sqlite file or pgdump output that is tracked in git. This is not the solution you're

Re: [sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-30 Thread 'Jonathan Vanasco' via sqlalchemy
ibute. > > Hope that helps, > > Simon > > On Fri, Jul 30, 2021 at 5:10 PM 'Jonathan Vanasco' via sqlalchemy > wrote: > > > > Mike, thanks for replying but go back to vacation. > > > > Anyone else: I am thinking more about an event that can be used to > cat

Re: [sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-30 Thread 'Jonathan Vanasco' via sqlalchemy
my.org/en/14/core/custom_types.html#coercing-encoded-strings-to-unicode > > > > On Thu, Jul 29, 2021, at 5:17 PM, 'Jonathan Vanasco' via sqlalchemy wrote: > > I am finally at the tail end of migrating my largest (and hopefully last) > Python2 application to Python3. > > A

[sqlalchemy] prevent (raise exceptions) on bytestring values for non-byte types

2021-07-29 Thread 'Jonathan Vanasco' via sqlalchemy
I am finally at the tail end of migrating my largest (and hopefully last) Python2 application to Python3. An issue that has popped up a lot during this transition, is when a py3 bytestring gets submitted into SqlAlchemy. When that happens, it looks like SqlAlchemy just passes the value into

[sqlalchemy] Re: checking in

2021-06-21 Thread 'Jonathan Vanasco' via sqlalchemy
> If not I wonder why messages aren't arriving in my INBOX. Check your settings for this group. If you do not see the option on the menu, try visiting https://groups.google.com/g/sqlalchemy/membership Google sometimes has a product change de-selects the email delivery option. Sometimes users

[sqlalchemy] Re: (cx_Oracle.DatabaseError) ORA-00972

2021-03-22 Thread 'Jonathan Vanasco' via sqlalchemy
Try passing a small number to `label_length` in your `create_engine`. Something like `label_length=5` might work. I typically use 4-6 on Production/Staging servers, and no argument on Development. *

Re: [sqlalchemy] Injecting User info into _history table to track who performed the change

2021-03-15 Thread 'Jonathan Vanasco' via sqlalchemy
Going beyond what Simon did.. I typically make make a table like `user_transaction`, which has all of the relevant information for the transaction: * User ID * Timestamp * Remote IP Using the sqlalchemy hooks, I'll then do something like: * update the object table with the user_transaction id

Re: [sqlalchemy] Supporting Function Indexes on a Minimum Sqlite Version

2021-03-09 Thread 'Jonathan Vanasco' via sqlalchemy
Thank you so much, Mike! I roughly had that same @compiles in my tests, but I didn't trust myself... and the .dbapi looked like what I wanted, but I really wasn't sure! On Monday, March 8, 2021 at 4:36:03 PM UTC-5 Mike Bayer wrote: > > > On Mon, Mar 8, 2021, at 12:06 PM, 'Jonathan Van

[sqlalchemy] Supporting Function Indexes on a Minimum Sqlite Version

2021-03-08 Thread 'Jonathan Vanasco' via sqlalchemy
I have a project that, in a few rare situations, may run on a version of sqlite that does not support function indexes, and "need" to run a unique index on `lower(name)`. For simplicity, I'll just use a normal index on correct systems, I'm trying to figure out the best way to implement this.

Re: [sqlalchemy] relationship query_class in SQLAlchemy 1.4.0b3

2021-03-01 Thread 'Jonathan Vanasco' via sqlalchemy
"is it better to think of rebuilding medium+ projects for 2.0 while maintaining existing codebases for 1.3? In other words, how much will 2.0 be backward compatible with 1.3?" I am saying the following as a general user, and not a past contributor to this project: As per the Release Status

Re: [sqlalchemy] Batching INSERT statements

2021-02-12 Thread 'Jonathan Vanasco' via sqlalchemy
I'm not familiar with this exactly, but have a bit of experience in this area. I just took a look at this module (nice work!). It's VERY well documented in the docstrings (even nicer work!) I think the core bit of this technique looks to be in `_get_next_sequence_values` -

[sqlalchemy] Re: Relationship with 2 intermediary tables

2021-02-12 Thread 'Jonathan Vanasco' via sqlalchemy
This is, IMHO, one of the most complex parts of SQLAlchemy. In this public project, i have a handful of secondary/secondaryjoin examples that may help you https://github.com/aptise/peter_sslers/blob/main/peter_sslers/model/objects.py#L3778-L4714 There is a section in the docs that should help

Re: [sqlalchemy] SQLAlchemy transaction ID

2021-01-27 Thread 'Jonathan Vanasco' via sqlalchemy
FWIW, within the realm of pyramid_tm, the more common use-cases for two-phase transaction support are for sending mail and a dealing with task queues - not two separate databases. On Wednesday, January 27, 2021 at 2:40:21 PM UTC-5 Mike Bayer wrote: > > > On Wed, Jan 27, 2021, at 2:23 PM,

Re: [sqlalchemy] FAQ or Feature Ideas for ORM Object and Session

2021-01-27 Thread 'Jonathan Vanasco' via sqlalchemy
Ok. I'll generate a docs PR for sqlalchemy and pyramid. this comes up so much. On Wednesday, January 27, 2021 at 2:25:29 PM UTC-5 Mike Bayer wrote: > > > On Wed, Jan 27, 2021, at 1:12 PM, 'Jonathan Vanasco' via sqlalchemy wrote: > > I've been working with a handful of SQLAlch

[sqlalchemy] FAQ or Feature Ideas for ORM Object and Session

2021-01-27 Thread 'Jonathan Vanasco' via sqlalchemy
I've been working with a handful of SQLAlchemy and Pyramid based projects recently, and two situations have repeatedly come up: 1. Given a SQLAlchemy Object, access the SQLAlchemy Session 2. Given a SQLAlchemy Object or Session, access the Pyramid Request object The general solutions I've used

[sqlalchemy] Re: SQLAlchemy transaction ID

2021-01-27 Thread 'Jonathan Vanasco' via sqlalchemy
Thierry, Would you mind putting together a test-case on this? I haven't experienced that before, and I authored that feature in the debugtoolbar. If I can recreate it, I'll put together a fix and work with the pyramid team to get a new release out asap. On Wednesday, January 27, 2021 at

Re: [sqlalchemy] Differences between TableClause insert and Model.__table__ inserts?

2020-11-25 Thread 'Jonathan Vanasco' via sqlalchemy
This was not clear enough in Mike's post: `Foo.__table__` is the same type of object as `_foo = table(...)`. SQLAlchemy ORM is built on top of SQLAlchemy's Core, so the ORM's `.__table__` attribute is the Core's `table()` object. Since they're the same, the two will have the same performance

[sqlalchemy] Re: Dis/Reassociate objects with a db session.

2020-11-25 Thread 'Jonathan Vanasco' via sqlalchemy
Read the docs on State Management and pay attention to `merge`: https://docs.sqlalchemy.org/en/14/orm/session_state_management.html Also, to simplify this stuff a popular related pattern is to use a RevisionID or RevisionTimestamp on the objects. In the first session, you note the version

[sqlalchemy] Re: Zope.sqalchemy: AttributeError: '_thread._local' object has no attribute 'value'

2020-10-25 Thread 'Jonathan Vanasco' via sqlalchemy
> territory before, and it's a codebase in which I'm still finding my way > (written by a codev) and yes, I might not spot what's taken for granted by > anyone more familiar with SQLAlchemy etc. - I've often been in the reverse > situation! > > On Saturday, October 24, 202

[sqlalchemy] Re: Zope.sqalchemy: AttributeError: '_thread._local' object has no attribute 'value'

2020-10-24 Thread Jonathan Vanasco
The extract code you posted is incorrect. You were given a step towards the right answer - you MUST invoke `register`. I say a step, because there may be other factors going on. However as you can see from the source code

[sqlalchemy] Re: migrating a child object from one parent to another

2020-09-24 Thread Jonathan Vanasco
I totally missed the `AcmeAccountKey.is_active.is_(True)` on the relationship. I set it as viewonly and crisis solved. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and

[sqlalchemy] migrating a child object from one parent to another

2020-09-24 Thread Jonathan Vanasco
I am having an issue with migrating an instance child relationship from one object to another. I have the following two classes: class AcmeAccount(Base): __tablename__ = "acme_account" id = sa.Column(sa.Integer, primary_key=True) account_url =

[sqlalchemy] Re: Update multiple rows in SQLite Databse

2020-08-28 Thread 'Jonathan Vanasco' via sqlalchemy
I believe your error is tied to this section of code: > for item in ingredDict: > ingredient_item = Ingredients(ingredientKey=item['ingredientKey'], > > ingredientDescription=item['ingredientDescription'], >

[sqlalchemy] Re: can't connect to Teradata - "The UserId, Password or Account is invalid"

2020-08-19 Thread Jonathan Vanasco
You will have better luck asking for help from the people who write/maintain the Teradata dialect. They list a gitter room here: https://github.com/Teradata/sqlalchemy-teradata According to a posting on gitter ( https://gitter.im/sandan/sqlalchemy-teradata), it looks like that package is

[sqlalchemy] Re: sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) ([Errno 13] Permission denied)")

2020-08-18 Thread Jonathan Vanasco
> using the same user and am able to connect from python terminal from the same linux box but it doesnt work using the python code. When this works in the terminal, how are you connecting? In Python via the database driver, or using the mysql client? If it's the mysql client, check the

[sqlalchemy] Re: compatibility between SQLite and PostgreSQL

2020-08-17 Thread Jonathan Vanasco
On Friday, August 14, 2020 at 10:00:46 AM UTC-4, Alceu Rodrigues de Freitas Junior wrote: > I have some projects that are using SQLAlchemy and PostgreSQL and they are > running fine until we have to run automated tests that uses PostgreSQL and > they took ~5 minutes to complete, even after

[sqlalchemy] Re: Deletion of a row from an association table

2020-08-11 Thread Jonathan Vanasco
Thanks. IIRC, I think you just need to set a custom cascade on these relationships (see https://docs.sqlalchemy.org/en/13/orm/cascades.html) I am not sure which option that would be, because it sounds like your application is behaving with a "delete-orphan", but that's not set. -- SQLAlchemy

[sqlalchemy] Re: Deletion of a row from an association table

2020-08-11 Thread Jonathan Vanasco
Can you share the full model for these 3 classes, which includes the relationship declarations? -- 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 Example. See

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

2020-07-10 Thread 'Jonathan Vanasco' via sqlalchemy
> 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 SQLAlchemy does do this, for those reasons, and to the columns...

Re: [sqlalchemy] Encrypt/Decrypt specific column(s)

2020-07-09 Thread 'Jonathan Vanasco' via sqlalchemy
On Thursday, July 9, 2020 at 2:12:36 PM UTC-4, Justvuur wrote: > > I've done some more digging... It seems when I did the search for > "secrets", the text is encrypted and compared to the value in the columns, > That is how client-side encryption works. If you want to search for "secrets",

Re: [sqlalchemy] convert subset to dictionary

2020-07-07 Thread 'Jonathan Vanasco' via sqlalchemy
Based on what you shared above: * The "Subject" table is: `StudentId, SubjectCode, SubjectName` * There are 181 subjects It looks like you don't have a "Subject" table, but a "StudentAndSubject" table. I think you'd have a bigger performance improvement by normalizing that data into two

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

2020-07-06 Thread 'Jonathan Vanasco' via sqlalchemy
On Monday, July 6, 2020 at 2:14:33 PM UTC-4, Saylee M. wrote: > So, when I passed the query to MySQL directly, it took very less time > (around 0.016 seconds) but when I passed the same > query through SQLAlchemy connector, it took around 600 seconds > "query ... MySQL directly" Do you

[sqlalchemy] Re: Locking method used in SQLAlchemy (postgres)

2020-06-30 Thread 'Jonathan Vanasco' via sqlalchemy
On Monday, June 29, 2020 at 8:00:40 PM UTC-4, gbr wrote: > > > I'm using SQLAlchemy's Core to interface a postgres database (via > psycopg2) component alongside Flask-SQLAlchemy in a Flask app. Everything > was working fine until I recently discovered what seems to be a deadlock > state which

[sqlalchemy] Re: Am I doing this query of lots of columns correctly?

2020-06-26 Thread 'Jonathan Vanasco' via sqlalchemy
that should be `loaded_columns_as_dict()` , unless you decorate the method with @property. -- 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 Example. See

[sqlalchemy] Re: Am I doing this query of lots of columns correctly?

2020-06-26 Thread 'Jonathan Vanasco' via sqlalchemy
I use a mixin class to handle this stuff. Example below. > So, my question: is it generally better practice to name every column that you want to pull, even if it's a long list? Not really. There is a "bundle" api here that might be better for you-

[sqlalchemy] Re: Can't find anything equivalent to bit_or in PostgreSQL

2020-06-16 Thread 'Jonathan Vanasco' via sqlalchemy
If this just needs this to be rendered for PostgreSQL, you can use the `func` generator: https://docs.sqlalchemy.org/en/13/core/sqlelement.html#sqlalchemy.sql.expression.func from sqlalchemy.sql.expression import func query = session.query(Foo).filter(func.bit_or(Foo.cola, Foo.colb)...

Re: [sqlalchemy] forcing (composite) primary key order?

2020-06-02 Thread Jonathan Vanasco
thanks mike! On Monday, June 1, 2020 at 7:15:23 PM UTC-4, Mike Bayer wrote: > > yes use the PrimaryKeyConstraint() construct > > > > https://docs.sqlalchemy.org/en/13/core/constraints.html?highlight=primarykeyconstraint#sqlalchemy.schema.PrimaryKeyConstraint > > here you'd want to put it in your

[sqlalchemy] forcing (composite) primary key order?

2020-06-01 Thread Jonathan Vanasco
is it possible to force the order of primary keys? for example in this setup... class AcmeDnsServer2Domain(Base): __tablename__ = "acme_dns_server_2_domain" acme_dns_server_id = sa.Column( sa.Integer, sa.ForeignKey("acme_dns_server.id"), primary_key=True ) domain_id =

[sqlalchemy] Re: Presenting a higher-level view of a physical table to the end-user

2020-05-31 Thread Jonathan Vanasco
How will the end-users be querying? Are they going to be consumers who are submitting params to a form, or are they going to be developers using Python/SqlAlchemy? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please

Re: [sqlalchemy] Re: how can i remove an entry from relational database using sqlalchemy in python

2020-05-30 Thread Jonathan Vanasco
If I had time to respond yesterday, I would have said the same thing as Simon. Your database model leverages two separate parts of SQLAlchemy: * SqlAlchemy ORM (Left side of the docs https://docs.sqlalchemy.org/en/13/ ) * SqlAlchemy Core (Right side of the docs

[sqlalchemy] Re: how can i remove an entry from relational database using sqlalchemy in python

2020-05-28 Thread Jonathan Vanasco
What is the code for PermissionEntity, ContractEntity, and the joining table? it will look like this https://docs.sqlalchemy.org/en/13/orm/basic_relationships.html#one-to-many -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example

[sqlalchemy] Re: how can i remove an entry from relational database using sqlalchemy in python

2020-05-28 Thread Jonathan Vanasco
Sorry, I meant the SqlAlchemy schema. I can't attempt to troubleshoot code that I can't see. -- 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 Example. See

[sqlalchemy] Re: how can i remove an entry from relational database using sqlalchemy in python

2020-05-28 Thread Jonathan Vanasco
can you share your schema for these 3 tables? -- 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 Example. See http://stackoverflow.com/help/mcve for a full

[sqlalchemy] Re: how can i remove an entry from relational database using sqlalchemy in python

2020-05-28 Thread Jonathan Vanasco
`.get()` returns the corresponding row/object based on the primary key https://docs.sqlalchemy.org/en/13/orm/query.html?highlight=get#sqlalchemy.orm.query.Query.get assuming `PermissionEntity` has a primary key of (permission_id, contact_id), the syntax from the examples would be: some_object

[sqlalchemy] Re: custom encryption for db columns/fields

2020-05-22 Thread Jonathan Vanasco
That would be purely PostgreSQL. You can look on StackOverflow for answers. Newer versions of postgresql also have a crypto library that can be compiled into the server, which may help. https://www.postgresql.org/docs/current/pgcrypto.html -- SQLAlchemy - The Python SQL Toolkit and Object

[sqlalchemy] Re: ImportError: No module named 'cx_Oracle' - Python3.6

2020-05-22 Thread Jonathan Vanasco
On Thursday, May 21, 2020 at 5:53:57 PM UTC-4, Thirsty ForKnowledge wrote: > > Hi, > > I am having an issue where a flask application is crashing with a 500 > Error. I upgraded from python 3.5 to 3.6 on linux: > When you upgrade Python, you need to (re)install all of the packages. Most

[sqlalchemy] Re: I have to create custom type in sqlAlchemy

2020-05-19 Thread Jonathan Vanasco
There is a section in the documentation titled "CustomTypes" The following example shows how to encode and decode JSON: https://docs.sqlalchemy.org/en/13/core/custom_types.html#marshal-json-strings Please be advised: If you store data in your own custom format, as you described, it will be

[sqlalchemy] Re: custom encryption for db columns/fields

2020-05-19 Thread Jonathan Vanasco
> On Tuesday, 19 May 2020 19:24:48 UTC+2, Justvuur wrote: >> >> Is it possible to create a custom encryption/decryption algorithm that >> can be used with sqlalchemy querying/filtering? >> When querying and filtering, I would like the field to automatically >> decrypt using the custom

[sqlalchemy] is it possible to implement this anti-pattern in SQLAlchemy?

2020-05-16 Thread Jonathan Vanasco
Ok never mind! I realized I could scrap this entire functionality and replace it with something else. The use-case was trying to detect the backup renewal options for SSL Certificates if the private key Or account key is revoked. (foo is an ACME order if available, bar is the certificate).

Re: [sqlalchemy] Passing reference to model to model column_property function

2020-05-16 Thread Jonathan Vanasco
It’s been a while since I’ve worked on stuff like this, but IIRC the simplest way was to use a function that accepts an ID and to flush in SqlAlchemy before executing it. Then you select the necessary row fields within the sql function, instead of passing args in or trying to pass a row in.

[sqlalchemy] is it possible to implement this anti-pattern in SQLAlchemy?

2020-05-15 Thread Jonathan Vanasco
I have two classes where one f-keys onto another. Things work perfectly: class Foo(Base): id = Column(Integer, primary_key=True) bar_id = Column(Integer, ForeignKey("bar.id"), nullable=True) bar = relationship( "bar", primaryjoin="Foo.bar_id==Bar.id",

Re: [sqlalchemy] hiding/encrypting the Oracle database connection information?

2020-05-15 Thread Jonathan Vanasco
There are two related concerns on this concept: * protecting your credentials in source code * protecting your credentials on the server For the first concern, I like to use encryption management tools like Blackbox (https://github.com/StackExchange/blackbox) With an encryption management

Re: [sqlalchemy] Best way to implement PostgreSQL materialized views?

2020-04-29 Thread Jonathan Vanasco
There also exists a 3rd party library that has been somewhat maintained: https://github.com/jklukas/sqlalchemy-views IIRC, it is largely based on the Wiki recipe that Mike linked to. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post

Re: [sqlalchemy] composite secondary join variant

2020-04-24 Thread Jonathan Vanasco
Thanks! That works exactly as I needed. I knew there was a problem in the secondaryjoin, so i commented it out. This works more intuitively than my other composite relationships, which are all more complex. The joining you used is: primaryjoin: A->B secondaryjoin: B->B2C secondary: B2C->C --

[sqlalchemy] Re: Consolidate multiple one-to-one into a list

2020-04-24 Thread Jonathan Vanasco
On Friday, April 24, 2020 at 1:16:10 PM UTC-4, Jens Troeger wrote: > > > If I understand you correctly, then the solution above is as good as it > gets and SQLA doesn’t provide a builtin solution for what I’m trying to do? > There are so many hooks in SqlAlchemy, there may still be a more

[sqlalchemy] composite secondary join variant

2020-04-23 Thread Jonathan Vanasco
i'm stuck on a variant of the Composite Secondary Join ( https://docs.sqlalchemy.org/en/13/orm/join_conditions.html#composite-secondary-joins ) I hope someone can see what my tired eyes are missing. I'm fairly certain the issue is in `secondary' and 'secondaryjoin'. I've tried a handful of

Re: [sqlalchemy] debugging DetachedInstanceError

2020-04-23 Thread Jonathan Vanasco
On Thursday, April 23, 2020 at 10:17:12 AM UTC-4, Mike Bayer wrote: > > Using the event hook is likely the most direct way to see where it's > happening, either via logging or pdb: > > >

[sqlalchemy] debugging DetachedInstanceError

2020-04-22 Thread Jonathan Vanasco
I'm trying to figure out how I got a DetatchedInstanceError DetachedInstanceError: Parent instance is not bound to a Session; lazy load operation of attribute 'domain' cannot proceed (Background on this error at: http://sqlalche.me/e/bhk3) This is happening in a web application where I

[sqlalchemy] Re: Consolidate multiple one-to-one into a list

2020-04-21 Thread Jonathan Vanasco
Assuming you are using declarative, this is okay ( https://docs.sqlalchemy.org/en/14/orm/mapping_api.html?#sqlalchemy.orm.Mapper ) Note this line: A class which was mapped by the sqlalchemy.ext.declarative

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 >

[sqlalchemy] Re: Consolidate multiple one-to-one into a list

2020-04-18 Thread Jonathan Vanasco
On Friday, April 17, 2020 at 8:02:50 PM UTC-4, Jens Troeger wrote: > > > Indeed, Child does have multiple parents… > Ok, so this isn't a one-to-one relationship, but a many-to-many relationship. I would opt for a 3 table structure: Parent Parent_2_Child Child The

[sqlalchemy] Re: Consolidate multiple one-to-one into a list

2020-04-14 Thread Jonathan Vanasco
This departs a bit from the example, because you are caching the youngest and oldest ids onto the Parent object. is that necessary for your usage? > Now my question is: how can I introduce a set/list of all children on the parent? The line you commented out from the example was either:

Re: [sqlalchemy] Re: ObjectDeletedError in master/slave configuration

2020-03-26 Thread Jonathan Vanasco
On Thursday, March 26, 2020 at 2:53:08 PM UTC-4, Mike Bayer wrote: > > is the issue that your follower database is only updating > asynchronously? I would likely organize the application to simply use two > different Session objects, one for master one for follower. Trying to do > it on a

[sqlalchemy] Re: ObjectDeletedError in master/slave configuration

2020-03-26 Thread Jonathan Vanasco
By default, SqlAlchemy has `expire_on_commit=True`. I'm going to poorly restate most of what Mike Bayer has told me in the past: the rationale behind this- an active Session is supposed to mirror the current state in the database; within a transaction we know the object values are equal to

[sqlalchemy] Re: ObjectDeletedError in master/slave configuration

2020-03-26 Thread Jonathan Vanasco
My first guess is two things are going on: 1. This is a behavior of `expire_on_commit` on the session. Once you commit on the Primary database, the object is stale. https://docs.sqlalchemy.org/en/13/orm/session_api.html 2. The session is then trying to read off a Secondary database, but the

Re: [sqlalchemy] Re: AM/PM question

2020-03-20 Thread Jonathan Vanasco
It doesn't matter when the time is entered or what it is supposed to reflect. The best option -- by a wide margin -- for storing any time values is in a TIMESTAMP column, and for storing date+time values is in a DATETIME column. These types of columns/fields/formats exist to streamline data

[sqlalchemy] Re: AM/PM question

2020-03-20 Thread Jonathan Vanasco
The common approach to this situation is storing the data as a 24hour timestamp in the database/sqlalchemy and converting it to a 12hour am/pm for display/editing. You could use a "12 hour" option and an enum column for am/pm or a string. You're going to have a much easier time in the longterm

[sqlalchemy] Re: Problem with inserting row containing a value with type PATH of postgres with geoalchemy2

2020-03-18 Thread Jonathan Vanasco
I'm glad it's up and running for you! -- 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 Example. See http://stackoverflow.com/help/mcve for a full description. ---

[sqlalchemy] Re: Warning about using backref with viewonly - how to make a two-way read-only relation?

2020-03-18 Thread Jonathan Vanasco
Tony, Mike helped me with a similar problem a few weeks ago: https://groups.google.com/d/msg/sqlalchemy/k4a-v2ebeJM/bj73xd4CFwAJ In his suggestion, I stash some mapper configuration data into `info`, then use the `mapper_configured` event to audit my configuration requirements. --

[sqlalchemy] Re: Problem with inserting row containing a value with type PATH of postgres with geoalchemy2

2020-03-17 Thread Jonathan Vanasco
On Tuesday, March 17, 2020 at 12:06:36 PM UTC-4, Christos Ch wrote: > > I am running a service from a docker container > The error is from psycopg2 and stating the function is not available on the PostgreSQL server. This is most likely because PostGIS is not installed on the server (which

[sqlalchemy] Re: Problem with inserting row containing a value with type PATH of postgres with geoalchemy2

2020-03-17 Thread Jonathan Vanasco
`st_geomfromewkt` is a function in the PostGIS extension to PostgreSQL. Are you certain postgis is installed in the server and enabled for the database? -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an

Re: [sqlalchemy] association_proxy

2020-03-16 Thread Jonathan Vanasco
On Monday, March 16, 2020 at 12:31:09 PM UTC-4, Mike Bayer wrote: > > I sometimes get a "moderators spam report" for SQLAlchemy and then I know > I have to go to the admin interface on the website. I likely approve them > really quick before you see them. as far as originals missing i dont

  1   2   3   4   5   6   7   8   9   10   >