473,479 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Using pysqlite2

Is it possible to use this for sending triggers to a sqlite db?Could
someone provide me with an example of how to do this please?
Thanks

Jun 2 '06 #1
3 1881
lo********@googlemail.com wrote:
Is it possible to use this for sending triggers to a sqlite db?Could
someone provide me with an example of how to do this please?
Thanks


Do you want to implement a trigger for a SQLite database in Python?

That won't work. Triggers in SQLite can only contain UPDATE, INSERT,
DELETE and SELECT statements http://sqlite.org/lang_createtrigger.html>.

Bye,
Dennis
Jun 2 '06 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dennis Benzinger wrote:
lo********@googlemail.com wrote:
Is it possible to use this for sending triggers to a sqlite db?Could
someone provide me with an example of how to do this please?
Thanks


Do you want to implement a trigger for a SQLite database in Python?

That won't work. Triggers in SQLite can only contain UPDATE, INSERT,
DELETE and SELECT statements http://sqlite.org/lang_createtrigger.html>.


Yes, but you can fake it.

You can create a new SQL function using pysqlite's create_function, and
then just call that function in the trigger. In that Python function from
the trigger, you can then even access SQLite again.

I've attached a quick-and-dirty example.

Note that exceptions in functions get ignored currently, so you better
implement a try-except with some kind of logging during development,
otherwise you will wonder why nothing happens.

Also, older pysqlite releases won't provide useful error messages if you
have errors in the SQL you send to executescript(). Using a recent pysqlite
release is recommended if you plan to use executescript().

- -- Gerhard
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEgMQrdIO4ozGCH14RArFaAKCU8lgwidMoNQ0GGKVwJ2 GV9xPF8ACfTDhv
QVHvudLfoDGiIyFgHe5w6L4=
=bfUa
-----END PGP SIGNATURE-----

Jun 2 '06 #3
Many thanks Gerhard - the solution you offer is workable in the scope
of my project.
Gracias muchacho
Xera121

Jun 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5866
by: rawCoder | last post by:
Hi All, I have a *.cer file, a public key of some one and I want to encrypt some thing using this public key. Can someone point me to a sample code for Encrypting some file using...
1
567
by: Mike | last post by:
When trying to compile (using Visual Web Developer 2005 Express Beta; frameworkv2.0.50215 ) the source code below I get errors (listed below due to the use of ICallBackEventHandler. Ultimately I...
10
2625
by: Christopher Benson-Manica | last post by:
Why can't I use a class destructor in a using declaration: using MyClass::~MyClass; ? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org ...
17
3477
by: beliavsky | last post by:
Many of my C++ programs have the line using namespace std; but the "Accelerated C++" book of Koenig and Moo has many examples where the library names are included one at a time, for example ...
8
4884
by: Petter Reinholdtsen | last post by:
I ran into a problem on HP-UX 11.00 the other day, where it refused to compile a program using 'using namespace std;' at the top. The reason seem to be that the compiler refuses to accept 'using...
14
2118
by: john.burton.email | last post by:
I've done some extensive searching and can't seem to find an answer to this - Is it correct to using "using" with templates, for example: using std::vector; Or do I need to specify the type...
5
2279
by: Michele Simionato | last post by:
An easy question, but I don't find the answer in the docs :-( I have a sqlite3 database containing accented characters (latin-1). How do I set the right encoding? For instance if I do this: #-*-...
0
1020
by: schwehr | last post by:
Hi All, I have some old pysqlite 1.x code that uses a pattern like this: cu.execute('SELECT weight FROM weights WHERE samplename="foo") row = cu.fetchone() weight=row It seems like lookups...
3
8202
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
0
6903
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6726
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5318
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4763
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2974
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
557
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
170
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.