How to get the version of a installed package using ocamlfind or opam? - opam

In my configure script, I need to check the installed version of a package <package> using ocamlfind or opam. How do I get this information?

Using ocamlfind: ocamlfind query -format %v <package>
This information is not directly available when running ocamlfind query --help, but it is available with ocamlfind query -help-format, which displays it among the other format options:
Formats for -format strings:
...
%v version
...
Using opam: opam info -f installed-version <package>
It returns -- when the package is not installed.
This comes from opam info --help:
-f FIELDS, --field=FIELDS
Only display the values of these fields. Fields can be selected
among name, version, package, synopsis, synopsis-or-target,
description, <field>:, installed-version, pin, source-hash,
opam-file, all-installed-versions, available-versions,
all-versions, repository, installed-files, vc-ref, depexts.
Multiple fields can be separated with commas, in which case field
titles will be printed; the raw value of any opam-file field can be
queried by suffixing a colon character (:), e.g. --field=depopts:.

Related

How can use the hstore extension type when migrating OSM data to PostGreSQL?

I am trying to migrate some Open Street Maps .osm.pbf file to my postgresql database using osm2pgsql on an ubuntu machine.
When I inspect the data after the process has been finished, the column for tags is types as text[] and filled with data like this:
{highway,residential,lit,yes,name,"St. Nicholas Street",name:en,"Saint Nicholas Street",name:mt,"Triq San Nikola"}
Question 1:
Is that an hstore type data? I can't seem to query it as if so. I tried this format:
SELECT * FROM planet_osm_ways WHERE tags ? 'highway' LIMIT 20;
yealding this error:
ERROR: operator does not exist: text[] ? unknown
LINE 1: ...T *, tags as tags FROM planet_osm_ways WHERE tags ? 'highway...
Question 2:
So assuming the error and format above means that the data was simply not saved as an hstore typed data, how can I correct my migration process to fix this?
My process:
Create a new database using pgAdmin 3 on linux ubuntu.
add hstore extension to database (pgAdmin)
add postgis extension to database (pgAdmin)
super user into postgres user in terminal
osm2pgsql -c -d <DB_NAME> <FILE_PATH> --slim --hstore --multi-geometry
run migration command:
sudo -u postgres -i
That's it, osm2pgsql does it's thing and gives out a successful output.
So what am i missing in this process?

bcp utility for Microsoft SQL Server ignores odd rows

I am trying to import a bunch of hashes into a SQL DB for testing purposes. The hashes are in the form of a text file looking like the following:
hash1
hash2
hash3
hash4
hash5
hash6
Now, for some reason, when I run the command bcp dbo.Table IN "Path\To\Dump.txt" -T -S SERVER\INSTANCE -d DB -c -t \n what happens is that every second hash is imported (i.e. hash2, hash4, and hash6). I have no idea why this is happening. Similarly, if I replace the delimiter argument with just \r or, \n\r, or \r\n, 0 rows get imported. Why is this happening?
It turns out I should have been referencing the View representing my hashes column instead of the whole table itself. That fixed things.

How to convert LDAP data (NTEXT) to String within an SSIS Package?

I'm currently using LDAP to grab User information within an SSIS package. I'm using an ADO.NET Datasource which is running this query:
SELECT sAMAccountName, cn, givenName, sn FROM 'LDAP://domainController' where objectClass='User'
The problem is, I would like to append the Domain suffix to the sAMAccountName since it is not included. Ex. " DOMAIN\ sAMAccountName" . However, I cannot figure out how to convert this data from Unicode Text Stream (DT_NTEXT) to String (DT_STR). Converting this column to String will allow me to append this suffix fairly easily using the Derived Column tool.
Is there a simple way of converting a DT_NTEXT to a DT_STR within my SSIS package?
Active Directory SSIS Data Source
I chain two data conversion tasks together "NTEXT -> TEXT" and then "TEXT -> STR" as you can see in the second screen shot. I don't have access to that package at the moment but something like 128 characters should be sufficiently wide.

How do I use BCP or Sql Server Management Studio to get BLOB data out of Sql Server?

I'm sorry if this question has been asked already, but I couldn't find it anywhere. I have a table that stores files as BLOBS. The column that holds the file is an image datatype. I would like to be able to extract the binary data out of the column and turn it in to an actual file. I would ideally like to be able to do this with BCP or management studio if possible.
I have tried BCP, but for some reason when I try and pull out an office document Word thinks it's corrupt. Here's what I've tried so far (obviously the values have been changed to protect the innocent :):
bcp "select document_binary_data from database where id = 12345" queryout "c:\filename.doc" -n -S server -U username -P password
This isn't working though? Any thoughts?
Edit Turns out you don't need the -n native flag. Also, BCP tries to include a 4 byte prefix by default on the image column - you actually want this set to 0.
bcp "select document_binary_data from database where id = 12345" queryout "c:\filename.doc" -S server -U username -P password
Enter the file storage type of field document_binary [image]:
Enter prefix-length of field document_binary [4]: 0
Enter length of field document_binary [0]:
Enter field terminator [none]:
I'm answering my own question since I'm getting annoyed with SO telling me to setup a bounty
Turns out you don't need the -n native flag. Also, BCP tries to include a 4 byte prefix by default on the image column - you actually want this set to 0.
bcp "select document_binary_data from database where id = 12345" queryout "c:\filename.doc" -S server -U username -P password
Enter the file storage type of field document_binary [image]:
Enter prefix-length of field document_binary [4]: 0
Enter length of field document_binary [0]:
Enter field terminator [none]:
If you can use C# / .NET code to do this, the following KB article may come in handy:
http://support.microsoft.com/kb/317016
Apparently you can do something like this with BCP and a format file, but IIRC the format file has to be pre-populated with the exact number of bytes it is expecting to pull from the column, which makes it quite impractical.
Another option you might choose is to use FILESTREAM in 2008 or, if you are not planning to migrate to 2008 anytime soon, store the documents on the file system and a pointer to them in the database. Yes there are pros and cons to this, but it's the way we've chosen in all projects to date.

How do I get more info for 'invalid format' error with onpladm on Windows?

This is my first time trying to use Informix. I have around 160 tables to load, using pipe-delimited text files. We have an older series of batch files that a previous developer wrote to load Informix data, but they're not working with the new version of Informix (11.5) that I installed. I'm running it on a Windows 2003 server.
I've modified the batch file to execute the onpladm commands for one file, so this batch file looks like this:
onpladm create project dif31US-1-table-Load
onpladm create object -F diffdbagidaxsid.dev
onpladm create object -F diffdbagidaxsid.fmt
onpladm create object -F diffdbagidaxsid.map
onpladm create object -F diffdbagidaxsid.job
When I run this, it successfully creates the project and device array,
but I get an error creating the format. The only error I get is:
Create object DELIMITEDFORMAT diffile1fmt failed!
Invalid format!
The diffdbagidaxsid.fmt file is as follows:
BEGIN OBJECT DELIMITEDFORMAT diffile1fmt
PROJECT dif31US-1-table-Load
CHARACTERSET ASCII
RECORDSTART
RECORDEND
FIELDSTART
FIELDEND
FIELDSEPARATOR |
BEGIN SEQUENCE
FIELDNAME agid
FIELDTYPE Chars
END SEQUENCE
BEGIN SEQUENCE
FIELDNAME axsid
FIELDTYPE Chars
END SEQUENCE
END OBJECT
As you can see, it is only 2 columns. It originally had nothing following the CHARACTERSET. I've tried it with ASCII, and with the numeric code for ASCII, and still get the same error.
Is there any way to get a more verbose error message?
Also, can anyone recommend a decent (meaning active community) forum for Informix? I've tried the old comp.databases.informix forum, http://www.dbforums.com, the 'official' forum on IBM DeveloperWorks, and here of course. None have very much activity. We have to do this testing because we have customers (or maybe just 1 big one) who uses it, so we have to test our data and API against it.
Succinctly, I don't think there is a way to get much more information out of onpladm.

Resources