Nova postagem

Pesquisar

Artigo
· Abr. 30 5min de leitura

SQLAchemy-iris avec la dernière version du pilote Python

Après tant d'années d'attente, nous avons enfin un pilote officiel disponible sur Pypi

De plus, j'ai découvert que le pilote JDBC était enfin disponible sur Maven depuis déjà 3 mois,  et le pilote .Net driver - surNuget depuis plus d'un mois.

 La mise en œuvre de la DB-API et que les fonctions devraient au moins être définies par cette norme. La seule différence devrait se situer au niveau de SQL.

Et ce qui est intéressant dans l'utilisation de bibliothèques existantes, c'est qu'elles ont déjà mis en œuvre d'autres bases de données en utilisant le standard DB-API, et que ces bibliothèques s'attendent déjà à ce que le pilote fonctionne.

J'ai décidé de tester le pilote officiel d'InterSystems en mettant en œuvre son support dans la bibliothèque SQLAlchemy-iris.

Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· Abr. 29

What is the REAL content of $THIS (because it seems, $THIS is not always the expected $THIS)?

According to documentation, quotation: "$THIS contains the current class context.
The class context for an instance method is the current object reference (OREF).
The class context for a class method is the current classname as a string value."
 
As my example below shows, either the documentation or the implementation (or both) is wrong, I always call a class method (Value) and expected the class name as the return value but got either the class name or an OREF. Moreover, if I repeat the call, I get another values. But why?
Does anyone have a clear explanation (for an aging brain) or have I misunderstood something?

Class DC.ValueOfThis Extends %RegisteredObject
{

ClassMethod Test()
{
	write $zv,!!
	set obj=..%New()
	do obj.Work()
	write "From classmethod: ",$this," ",$this," ",..Value()," ",..Value()," ",..Value()," ",$this,!
	do obj.Work()
}

Method Work()
{
	write "From inst.method: ",$this," ",$this," ",..Value()," ",..Value()," ",..Value()," ",$this,!
}

ClassMethod Value()
{
	quit $this
}

}

And the test output is:

USER>

USER>d ##class(DC.ValueOfThis).Test()
IRIS for UNIX (Ubuntu Server LTS for x86-64) 2021.2 (Build 649U) Thu Jan 20 2022 08:49:51 EST

From inst.method: 1@DC.ValueOfThis 1@DC.ValueOfThis DC.ValueOfThis 1@DC.ValueOfThis 1@DC.ValueOfThis 1@DC.ValueOfThis
From classmethod: DC.ValueOfThis DC.ValueOfThis DC.ValueOfThis DC.ValueOfThis DC.ValueOfThis DC.ValueOfThis
From inst.method: 1@DC.ValueOfThis 1@DC.ValueOfThis 1@DC.ValueOfThis 1@DC.ValueOfThis 1@DC.ValueOfThis 1@DC.ValueOfThis

USER>
4 Comments
Discussão (4)4
Entre ou crie uma conta para continuar
Resumo
· Abr. 29

A chance to win the InterSystems READY 2025 pass and hotel!

Dear Developer Community member,

There's still time to take part in our developer challenge to win hotel accommodation and free passes to the InterSystems READY 2025!

🎯 Code Your Way to InterSystems READY 2025

Duration: April 21 - May 04, 2025

Task:

  1. Upload an IRIS-based side project to Open Exchange. Be creative - it can be useful, quirky, fun, or just something you've always wanted to try.
  2. Record a short inspirational video (up to 5 minutes):
    • Tell us how InterSystems technologies or the Developer Community impacted your project or career.
    • Explain why YOU should get a ticket to the InterSystems READY 2025.
  3. Submit your video and a link to your app via this form.

>> Full details here

Let's celebrate creativity together. Get ready for the future!

Pergunta
· Abr. 29

How to access a stream property in a SQL trigger

I have an IRIS persistent class with a %Stream property whose value is a JSON object. I'd like to use a SQL trigger to pull some value out of the JSON and persist it in another property, for easy querying and indexing. See below for a minimal example:

Class PAB.DebugStream Extends %Persistent
{

Property Contents As %Stream.GlobalCharacter;
Property msg As %String;
ClassMethod InsertRow()
{
    set stream = ##class(%Stream.GlobalCharacter).%New()
    $$$ThrowOnError(stream.Write({"msg":"hello world!"}))
    &sql(insert into PAB.DebugStream (Contents) values (:stream))
    $$$ThrowSQLIfError(SQLCODE, %msg)
}

Trigger ExtractKeys [ Event = INSERT/UPDATE, Foreach = row/object, Time = AFTER ]
{
    new contentsJSON, id, msg
    if {Contents*C} {
        set contentsJSON = {}.%FromJSON({Contents})
        set id = {ID}
        set msg = contentsJSON.msg
        &sql(update PAB.DebugStream set msg = :msg where Id = :id)
        $$$ThrowSQLIfError(SQLCODE, %msg)
    }
}
}

However, the SQL insert fails in the trigger with a JSON parsing message like this:

<THROW>InsertRow+9^PAB.DebugStream.1 *%Exception.SQL -415 -415 InsertRow+9^PAB.DebugStream.1 Error occurring during INSERT in table 'PAB.DebugStream':  $ZE=<THROW>%FromJSON+22^%Library.DynamicAbstractObject.1 *%Exception.General Parsing error 3 Line 1 Offset 1

If I log the value of {Contents} in the trigger, it's not the stream object as I expect but an integer value.

How can I get the new value of a %Stream property in a SQL trigger?

I'm also open to suggestions about better ways to persist/index specific paths in a JSON property.

2 Comments
Discussão (2)1
Entre ou crie uma conta para continuar
Anúncio
· Abr. 29

Préparez-vous, soyez prêt, obtenez la certification !

Vous prévoyez de participer à l'InterSystems READY 2025 (du 22 au 25 juin), le sommet mondial de cette année ?

Get Certified at InterSystems READY 2025, June 23-25, Orlando, FL

🏁 Si oui, tentez votre examen de certification gratuitement !

Prouvez vos compétences en technologie InterSystems et obtenez notre certification de haut niveau dans l'un des huit domaines proposés.

Examens inclus :

  • Spécialiste d'interface InterSystems HL7®
  • Spécialiste InterSystems IRIS SQL
  • Spécialiste technique HealthShare Unified Care Record

👩‍💻Si vous êtes titulaire de la certification Spécialiste InterSystems SQL, vous pouvez également passer le nouvel examen InterSystems IRIS SQL Professional (en version bêta) !

Consultez la liste complète des examens disponibles. Préparez-vous dès maintenant et réservez votre place !

👉 Obtenez votre certification à READY 2025 !

Discussão (0)1
Entre ou crie uma conta para continuar