Re: [sqlalchemy] Re: create database name lowcase ?

2022-03-31 Thread Massimiliano della Rovere
Postgresql is case case insensitive unless you impose a specific casing using " (double quotes): they are valid everywhere postgresql expects an identifier (schema name, table name, column name, cte name, after AS, etc. So it's all correct. See

Re: [sqlalchemy] Postgresql JSON object update.

2021-05-24 Thread Massimiliano della Rovere
ope that helps, > > Simon > > On Mon, May 24, 2021 at 4:12 PM Massimiliano della Rovere > wrote: > > > > In postgresql the || operator is the only way (no, the concat() function > doesn't work) to concat 2 JSONB dicts; note that this works only with JSONB > and not J

[sqlalchemy] Postgresql JSON object update.

2021-05-24 Thread Massimiliano della Rovere
In postgresql the || operator is the only way (no, the concat() function doesn't work) to concat 2 JSONB dicts; note that this works only with JSONB and not JSON. Example: suppose column "t.c" contains '{"a": 1}'::jsonb SELECT t.c || jsonb_build_object('b', 2); gives {"a": 1, "b": 2}

[sqlalchemy] postgresql JSON(B) dialect: update value of a specific key in a JSON object

2020-10-16 Thread Massimiliano della Rovere
Greetings, how should I write the .values() section of a CORE update() statement to render the following postgres syntax? The data column is a JSON(B) and contains a dict object. UPDATE settings SET data = data || '{"key": "value"}' WHERE key = 'my_param'; Thanks, Massimiliano -- SQLAlchemy -

[sqlalchemy] question :)

2020-10-09 Thread Massimiliano della Rovere
Greetings, is it possible using sqlalchemy core to obtain the following code: [...] WHERE (column1, column2) = (value1, value2) this is useful to use multi columnar indexes having column1 and column2 in the two leftmost position and in later position columns that I put in the SELECT section. --

[sqlalchemy] Documentation hint

2020-10-09 Thread Massimiliano della Rovere
Greetings, probably it's obvious to everybody but me, but I think it would be useful specifying in both the literal and the bindparam documentation that literal(bindparam(...)) is an invalid construct in sqlalchemy -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper

[sqlalchemy] stream_results cursor name

2020-10-05 Thread Massimiliano della Rovere
When using .execution_options(stream_results=True), is it possible to pass the cursor name too? -- 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

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

2020-09-15 Thread Massimiliano della Rovere
{"timestamps": {"foo": "bar"}}) > > > > > On Tue, Sep 15, 2020, at 11:50 AM, Mike Bayer wrote: > > this indicates a bindparam() object is being interpreted as a value > somewhere but I can't reproduce that. > > can you provide an MCVE

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

2020-09-15 Thread Massimiliano della Rovere
"preparing" of queries? Il giorno mar 15 set 2020 alle ore 17:13 Mike Bayer < mike...@zzzcomputing.com> ha scritto: > the dictionary is with column names as keys: > > > set_={"data": bindparam("timestamps")} > > hope this helps > > > >

[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

[sqlalchemy] Hoarded RAM

2020-07-02 Thread Massimiliano della Rovere
Greetings, I am using * SQLAlchemy: 1.3.3 * psycopg2-binary: 2.8.3 * postgresql: 9.6 While running a SQLAlchemy CORE script that makes lots of updates (about 300k), some inserts (about 50k) and commits data only at the end, the script consumes about 8GB+ RAM (well... we have to stop it to avoid

Re: [sqlalchemy] SQLAlchemy CORE: bindparam()-like solution but for the type_ argument of func.cast()

2020-04-06 Thread Massimiliano della Rovere
Il giorno lun 6 apr 2020 alle ore 16:30 Mike Bayer ha scritto: > > On Mon, Apr 6, 2020, at 5:42 AM, Massimiliano della Rovere wrote: > > In SQLAlchemy CORE is there any way to use bindparam() to late-bind the > type_ parameter of the func.cast function instead of a column? > &g

[sqlalchemy] SQLAlchemy CORE: bindparam()-like solution but for the type_ argument of func.cast()

2020-04-06 Thread Massimiliano della Rovere
In SQLAlchemy CORE is there any way to use bindparam() to late-bind the type_ parameter of the func.cast function instead of a column? I wrote a function returning a "baked query", that extracts settings stored in a XML column. I want the extracted value to be cast to a type depending on the

Re: [sqlalchemy] generate_series?

2019-07-30 Thread Massimiliano della Rovere
Years later... please can you give me some hints on how to write the Alias subclass and the function to decorate with @complile? I'm not expert with SQLAlchemy internals. Il giorno martedì 4 marzo 2014 17:14:56 UTC+1, Michael Bayer ha scritto: > > if you want to select columns from a function

[sqlalchemy] Writing a Table that changes its schema and name if ii's used with PostgreSQL or Oracle

2017-11-30 Thread Massimiliano della Rovere
Greetings, I'm writing to ask some hints for my problem. I am using SQLAlchemy Core (no ORM, because everything it is wrapped by sqlachemy_aio - everything happens inside a asyncio loop). The program I'm working on can be deployed with a PostgreSQL or an Oracle DB, customer choice, I have no

Re: [sqlalchemy] lowercase identifiers in Oracle

2015-10-05 Thread Massimiliano della Rovere
quot; ( "pkey" int PRIMARY KEY, "field1" int, "field2" varchar(10), "ref" int REFERENCES "MYSCHEMA"."x" ("pkey") ); Thanks, Massimiliano Il giorno venerdì 2 ottobre 2015 17:12:12 UTC+2, Michael Bayer ha scritto: >

Re: [sqlalchemy] lowercase identifiers in Oracle

2015-10-05 Thread Massimiliano della Rovere
no venerdì 2 ottobre 2015 17:12:12 UTC+2, Michael Bayer ha scritto: > > > > On 10/2/15 9:44 AM, Massimiliano della Rovere wrote: > > cx-Oracle==5.2 > SQLAlchemy==1.0.8 > > I'm in the weird situation of dealing with an Oracle database with > lowercase identifiers (they were

Re: [sqlalchemy] lowercase identifiers in Oracle

2015-10-05 Thread Massimiliano della Rovere
quot; Table( quoted_name(tablename, quote=True), metadata, schema=schemaname, autoload=True, extend_existing=True) Il giorno venerdì 2 ottobre 2015 17:12:12 UTC+2, Michael Bayer ha scritto: > > > > On 10/2/15 9:44 AM, Massimiliano della Rovere wrote: > &g

[sqlalchemy] lowercase identifiers in Oracle

2015-10-02 Thread Massimiliano della Rovere
cx-Oracle==5.2 SQLAlchemy==1.0.8 I'm in the weird situation of dealing with an Oracle database with lowercase identifiers (they were created by another software that escapes always table/schema/index identifiers). I get a "NoSuchTableError" whenever I issue a MetaData(bind=engine,

[sqlalchemy] Is there a better and more idiomatic way to accomplish this?

2015-10-01 Thread Massimiliano della Rovere
Greetings, I have two questions to the following code that works, but looks dirty to me. Being new to SQLAlchemy I'd like to ask for advices. The database is PostgreSQL. The following check_xyz function must check whether the index "table_xyz_idx" exists in table "table". The table surely