Template version Lotus Notes - templates

I need to create a view in a BD(a admin db kinnd) that shows me the template version of all the other databases!
can anyone help me with this please!?

You don't need to create a database for this purpose, there is already one. It is called "catalog.nsf" and contains the Information you want. You just need to create a view and modify the selection- formula slightly:
Original:
SELECT #IsAvailable(ReplicaID)& #IsUnavailable(RepositoryType)& !(DBListInCatalog = "0")
New:
SELECT #IsAvailable(ReplicaID)& #IsUnavailable(RepositoryType)
That way you see all databases, even the ones that normally are not visible in catalog.
The information you are looking for is in the "DbInheritTemplateName"- Field.
If you want to code this yourself, you can either run through all documents in the catalog.nsf and read it from there or you use a NotesDBDirectory, run through it and read the "DesignTemplateName"- property of NotesDatabase- Class.
Example code for catalog:
Dim dbCatalog as NotesDatabase
Dim dc as NotesDocumentCollection
Dim doc as NotesDocument
Dim strTemplate as String
Set dbCatalog = New NotesDatabase( "YourServerName" , "catalog.nsf" )
Set dc = dbCatalog.Search( "#IsAvailable(ReplicaID)& #IsUnavailable(RepositoryType)", Nothing, 0 )
Set doc = dc.GetFirstDocument()
While not doc is Nothing
strTemplate = doc.GetItemValue( "DBInheritTemplateName" )(0)
'- do whatever you want: create a document in your database, create a list...
Set doc = dc.GetNextDocument(doc)
Wend
Example code for NotesDBDirectory
Dim dbDirectory as New NotesDBDirectory( "YourServerName" )
Dim db as NotesDatabase
Dim strTemplate as String
Set db = dbDirectory.GetFirstDatabase( DATABASE )
While not db is Nothing
strTemplate = db.DesignTemplateName
'- do whatever you want: create a document in your database, create a list...
Set db = dbDirectory.GetNextDatabase
Wend

As Panu stated, a database catalog provides a list of all databases on a server. You use the server Catalog task to create a database catalog. The Catalog task bases the catalog file (CATALOG.NSF) on the CATALOG.NTF template and adds the appropriate entries to the catalog's ACL. All databases on a server are included in the catalog when the Catalog task runs.
To help users locate databases across an organization, or to keep track of all the replicas for each database, you must set up a Domain Catalog -- a catalog that combines the information from the database catalogs of multiple servers -- on one of your servers. You can set up a Domain Catalog regardless of whether you plan to implement Domino's Domain Search capability.
Besides allowing users to see what databases are on a particular server, catalogs provide useful information about databases. For each database in a view, a Database Entry document provides information such as file name, replica ID, design template, database activity, replication, full-text index, and ACL, as well as buttons that let users browse the database or add it to their bookmarks. In addition, the document displays a link to the database's Policy (About This Database) document, which, for databases users are not authorized to access, they can view by sending an e-mail request to the database manager.
See the Domino Admin Help for more details.

Related

Can I set a dynamic database as a source for a dataset?

I have multiple databases which have the same exact schema (different data on each one, database per customer of a SaaS platform).
I would like to create a Dashboard (with charts, datasets) which could be populated by the permissions of the logged in user.
This means the dashboard will query the data from a specified source database, instead of a pre-defined one.
The premise is basically to de-couple a chart / dataset from a database and allow it to be parametrised.
This is a case that is not really supported by Superset, but there's one workaround that I can think of that might work: you can define a DB_CONNECTION_MUTATOR in your superset_config.py that routes to a different database depending on the user.
In your superset_config.py, add this function:
def DB_CONNECTION_MUTATOR(uri, params, username, security_manager, source):
user = security_manager.find_user(username=username)
if url.database = "db_name" and user and user.email.endswith("#examplea.com"):
uri.host = "host-for-examplea.com"
return uri, params
In the function above we're changing the host of the SQLAlchemy URL to host-for-examplea.com if the user has an email ending in #examplea.com.
To make it work, create a default database (which we called db_name in this example), and create all the charts/dashboards based on it. Then, users should be redirected to specific databases by the DB_CONNECTION_MUTATOR.
One serious problem that might happen is with caching, though. You should make sure that all caches are disabled to prevent users from seeing data from other databases.

Oracle APEX - find pages that contain a particular region type

Is there a way to get list of pages in Oracle APEX where a particular region exists? For example get a list of all pages that contain Breadcumbs or Classic Report
Absolutely! In fact, this is one of the advantages of APEX being a metadata-driven framework. Go to the Application Builder > Workspace Utilities > Application Express Views. That will give you a listing of all of the views available for you to run the type of reports you're asking about. The Query By Example pages there can be helpful, or you can start running queries in the SQL Workshop:
select application_id,
application_name,
page_id,
page_name,
component_signature
from apex_application_page_regions
where instr(component_signature, 'NATIVE_BREADCRUMB') > 0
Other regions have different signatures, like NATIVE_SQL_REPORT (Classic Report), NATIVE_IG (Interactive Grid), and NATIVE_IR (Interactive Report).
Also, when you're at Application Builder > Workspace Utilities, look on the right for a number of more "canned" reports you may find useful.
This is relatively easy to figure out. You have access to the public apex views that are like a data dictionary on top of the apex metadata. The best way to start is to check who the apex user is by running the following query:
select distinct owner from all_objects where object_name like 'APEX%';
Then use the user that corresponds to your version (in my case that is APEX_190100 since I'm on 19.1) and list all apex views
select * from all_objects where owner = 'APEX_190100';
That list isn't that long you'll quickly find the view you need. Query that view by application_id and look for the information you need. In your case that probably is
SELECT * FROM apex_application_page_regions;
Breadcrumbs has its own view: APEX_APPLICATION_BREADCRUMBS.
You can also see the list of Application Express views (and a short description) via app builder > workspace utilities > Application Express Views

Syncing db with existing tables through django for an existing schema table and also updating few columns for the tables and the rest automatically

I am doing a poc in Django and i was trying to create the admin console module for inserting,updating and deleting records through django admin console through models and it was doing fine
I have 2 questions.
1.I need to have model objects for existing tables which needs to be present in a particular schema.say schema1.table1
Here as of now i was doing poc for public schema.
So can it be done in a fixed defined schema and if yes how.Any reference would be very helpful
2.Also i wanted to update few columns in the table through console and the rest of the columns will be done automatically like currentimestamp and created date etc.Is it possible through default django console and if yes kindly share any reference
Steps for 1
What i have done as of now is created a class in model.py with attributes as author,title,body,timeofpost
Then i used sqlmigrate after makemigrations app to create the table and after migrating have been using the admin console for django to insert and update the records for the table created.But this is for POC only.
Now i need to do the same but for existing tables with whom i can interact and insert or update record for those existing tables through admin console.
Also the tables are getting created in public schema by default.But i am using postgres and the existing tables are present in different schemas and i wanted to insert,update and delete for this existing tables.
I am stuck up here as i dont know how to configure model with existing database schema tables through which we can interact through django console and also for different schemas and not in public schema
Steps for 2:
Also i wanted the user to give input for few columns like suppose in this case time of creation is not required to be given as input by user .Rather it should be taken care when the database is updating or creating
Thanks
In order for Django to "interact" with an existing database you need to create a model for it which can be done automatically as shown here. This assumes that your "external" database isn't going to be changed often because you'll have to keep your models in sync which is tricky - there are other approaches if you need that.
As for working with multiple database schemas - is there a reason you can't put your POC table in the same database as the others? Django supports multiple databases, but it will be harder to setup. See here.
Finally, it sounds like you are interested in setting the Django default field attribute. For an example of current time see here.

Sitecore Analytics reports - Is this only for Analytics database, can I use master database to generate reports?

I was trying to create a report from master database in analytics reports. (Stimulsoft Report Designer)
As it explains in the reports cookbook, I have created a "mrt file" (Report UI) and a report definition item in Engagement analytics.
I have configured the datasource item as query item
(/sitecore/system/Settings/Analytics/Reports SQL Queries/Visit Pages).
It worked.
But then I tried with a query using the master database, in the SQL query item I specifically mentioned the database as 'testProjectMaster' to point to master database. It did not work!
Then I figured out that in "/sitecore/system/Settings/Analytics/Reports SQL Queries/Visit Pages" item and other query items, it does not specify the database, that means by default sitecore queries the analytics database.
Is this a limitaion in sitecore, cant we query the master databse for reports? Are there any good resources to follow on creating reports?
I suggest taking the SQL from the Visit Pages report and running it in SQL Server Management Studio. There, you will be able to quickly see what's preventing your query from running. If I had to venture a guess, I would suspect that your SQL user account does not have db_datareader access to the master database.
The default SQL queries provided by Sitecore assume that the DMS is configured as the default database in the connection string. This, however, does not prevent you from querying other databases or doing cross-database joins like so:
SELECT TOP 100 * FROM Pages
INNER JOIN Sitecore_Master.dbo.Items AS MasterItems ON Pages.ItemId = MasterItems.ID
A word of caution.. from my experience, this can really slow down your reports as it does not take advantage of indexing and creating indexed views doesn't work across multiple databases.

Making sharding simple with Django

I have a Django project based on multiple PostgreSQL servers.
I want users to be sharded across those database servers using the same sharding logic used by Instagram:
User ID => logical shard ID => physical shard ID => database server => schema => user table
The logical shard ID is directly calculated from the user ID (13 bits embedded in the user id).
The mapping from logical to physical shard ID is hard coded (in some configuration file or static table).
The mapping from physical shard ID to database server is also hard coded. Instagram uses Pgbouncer at this point to retrieve a pooled database connection to the appropriate database server.
Each logical shard lives in its own PostgreSQL schema (for those not familiar with PostgreSQL, this is not a table schema, it's rather like a namespace, similar to MySQL 'databases'). The schema is simply named something like "shardNNNN", where NNNN is the logical shard ID.
Finally, the user table in the appropriate schema is queried.
How can this be achieved as simply as possible in Django ?
Ideally, I would love to be able to write Django code such as:
Fetching an instance
# this gets the user object on the appropriate server, in the appropriate schema:
user = User.objects.get(pk = user_id)
Fetching related objects
# this gets the user's posted articles, located in the same logical shard:
articles = user.articles
Creating an instance
# this selects a random logical shard and creates the user there:
user = User.create(name = "Arthur", title = "King")
# or:
user = User(name = "Arthur", title = "King")
user.save()
Searching users by name
# fetches all relevant users (kings) from all relevant logical shards
# - either by querying *all* database servers (not good)
# - or by querying a "name_to_user" table then querying just the
# relevant database servers.
users = User.objects.filter(title = "King")
To make things even more complex, I use Streaming Replication to replicate every database server's data to multiple slave servers. The masters should be used for writes, and the slaves should be used for reads.
Django provides support for automatic database routing which is probably sufficient for most of the above, but I'm stuck with User.objects.get(pk = user_id) because the router does not have access to the query parameters, so it does not know what the user ID is, it just knows that the code is trying to read the User model.
I am well aware that sharding should probably be used only as a last resort optimization since it has limitations and really makes things quite complex. Most people don't need sharding: an optimized master/slave architecture can go a very long way. But let's assume I do need sharding.
In short: how can I shard data in Django, as simply as possible?
Thanks a lot for your kind help.
Note
There is an existing question which is quite similar, but IMHO it's too general and lacks precise examples. I wanted to narrow things down to a particular sharding technique I'm interested in (the Instagram way).
Mike Clarke recently gave a talk at PyPgDay on how Disqus shards their users with Django and PostgreSQL. He wrote up a blog post on how they do it.
Several strategies can be employed when sharding Postgres databases. At Disqus, we chose to shard based on table name. Where as the original table name as generated by Django might be comments_post, our sharding tools will rewrite the SQL to query a table comments_post_X, where X is the shard ID calculated based on a consistent hashing scheme. All these tables live in a single schema, on a single database instance.
In addition, they released some code as part of a sample application demonstrating how they shard.
You really don't want to be in the position of asking this question. If you are sharding by user id then you probably don't want to search by name.
If you are sharding your database then it's not going to be invisible to your application and will probably end up requiring schema alterations.
You might find SkyTools useful - read up on PL/Proxy. It's how Skype shard their databases.
it is better to use professional sharding middleware, for example: Apache ShardingSphere.
The project contains 2 productions, ShardingSphere-JDBC for java driver, and ShardingSphere-Proxy for all programing languages. It can support python and Django as well.